package handling.channel.handler;

import client.MapleCharacter;
import client.MapleClient;
import client.MapleDisease;
import client.MapleQuestStatus;
import client.MapleStat;
import client.MapleTrait;
import client.PlayerStats;
import client.Skill;
import client.SkillFactory;
import client.anticheat.CheatingOffense;
import client.inventory.Equip;
import client.inventory.Item;
import client.inventory.ItemFlag;
import client.inventory.MapleInventory;
import client.inventory.MapleInventoryType;
import client.inventory.MapleMount;
import client.inventory.MaplePet;
import constants.GameConstants;
import database.DatabaseConnection;
import handling.world.MaplePartyCharacter;
import handling.world.World;
import handling.world.World.Broadcast;
import java.awt.Point;
import java.awt.Rectangle;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.locks.Lock;
import scripting.NPCScriptManager;
import server.MapleInventoryManipulator;
import server.MapleItemInformationProvider;
import server.MapleStatEffect;
import server.RandomRewards;
import server.Randomizer;
import server.ScriptedItem;
import server.ServerProperties;
import server.StructItemOption;
import server.StructRewardItem;
import server.life.MapleLifeFactory;
import server.life.MapleMonster;
import server.maps.FieldLimitType;
import server.maps.MapleMap;
import server.maps.MapleMapItem;
import server.maps.MapleMapObject;
import server.maps.MapleMapObjectType;
import server.maps.SavedLocationType;
import server.quest.MapleQuest;
import server.shops.HiredMerchant;
import server.shops.IMaplePlayerShop;
import tools.FileoutputUtil;
import tools.MaplePacketCreator;
import tools.Pair;
import tools.data.LittleEndianAccessor;
import tools.packet.MTSCSPacket;
import tools.packet.PlayerShopPacket;

public class InventoryHandler {

    public static final int OWL_ID = 1;

    public static void ItemMove(LittleEndianAccessor slea, MapleClient c) {
        if (c.getPlayer().hasBlockedInventory()) {
            return;
        }
        c.getPlayer().setScrolledPosition((short) 0);
        c.getPlayer().updateTick(slea.readInt());
        MapleInventoryType type = MapleInventoryType.getByType(slea.readByte());
        short src = slea.readShort();
        short dst = slea.readShort();
        short quantity = slea.readShort();
        if ((src < 0) && (dst > 0)) {
            MapleInventoryManipulator.unequip(c, src, dst);
        } else if (dst < 0) {
            MapleInventoryManipulator.equip(c, src, dst);
        } else if (dst == 0) {
            MapleInventoryManipulator.drop(c, type, src, quantity);
        } else {
            MapleInventoryManipulator.move(c, type, src, dst);
        }
        if (ServerProperties.IsLvkejian()) {
            String 信息 = new StringBuilder().append("时间: ").append(FileoutputUtil.CurrentReadable_Time()).append(" 客户端处理 ItemMove ").append(c.getPlayer().getName()).append("  ").append(" dst: ").append(dst).append(" src: ").append(src).toString();

            FileoutputUtil.packetLog("log\\穿戴装备信息.log", 信息);
        }
    }
    
    public static void SwitchBag(LittleEndianAccessor slea, MapleClient c) {
        if (c.getPlayer().hasBlockedInventory()) {
            return;
        }
        c.getPlayer().setScrolledPosition((short) 0);
        c.getPlayer().updateTick(slea.readInt());
        short src = (short) slea.readInt();
        short dst = (short) slea.readInt();
        if ((src < 100) || (dst < 100)) {
            return;
        }
        MapleInventoryManipulator.move(c, MapleInventoryType.ETC, src, dst);
    }

    public static void MoveBag(LittleEndianAccessor slea, MapleClient c) {
        if (c.getPlayer().hasBlockedInventory()) {
            return;
        }
        c.getPlayer().setScrolledPosition((short) 0);
        c.getPlayer().updateTick(slea.readInt());
        boolean srcFirst = slea.readInt() > 0;
        short dst = (short) slea.readInt();
        if (slea.readByte() != 4) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        short src = slea.readShort();
        MapleInventoryManipulator.move(c, MapleInventoryType.ETC, srcFirst ? dst : src, srcFirst ? src : dst);
    }

    public static void ItemSort(LittleEndianAccessor slea, MapleClient c) {
        c.getPlayer().updateTick(slea.readInt());
        c.getPlayer().setScrolledPosition((short) 0);
        MapleInventoryType pInvType = MapleInventoryType.getByType(slea.readByte());
        if ((pInvType == MapleInventoryType.UNDEFINED) || (c.getPlayer().hasBlockedInventory())) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        MapleInventory pInv = c.getPlayer().getInventory(pInvType);
        boolean sorted = false;
        while (!sorted) {
            byte freeSlot = (byte) pInv.getNextFreeSlot();
            if (freeSlot != -1) {
                byte itemSlot = -1;
                for (byte i = (byte) (freeSlot + 1); i <= pInv.getSlotLimit(); i = (byte) (i + 1)) {
                    if (pInv.getItem((short) i) != null) {
                        itemSlot = i;
                        break;
                    }
                }
                if (itemSlot > 0) {
                    MapleInventoryManipulator.move(c, pInvType, (short) itemSlot, (short) freeSlot);
                } else {
                    sorted = true;
                }
            } else {
                sorted = true;
            }
        }
        c.getSession().write(MaplePacketCreator.finishedSort(pInvType.getType()));
        c.getSession().write(MaplePacketCreator.enableActions());
    }

    public static void ItemGather(LittleEndianAccessor slea, MapleClient c) {
        c.getPlayer().updateTick(slea.readInt());
        c.getPlayer().setScrolledPosition((short) 0);
        if (c.getPlayer().hasBlockedInventory()) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        byte mode = slea.readByte();
        if (mode == 5) {
            c.getPlayer().dropMessage(1, "特殊栏道具暂不开放已种类道具排列.");
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        MapleInventoryType invType = MapleInventoryType.getByType(mode);
        MapleInventory Inv = c.getPlayer().getInventory(invType);

        List<Item> itemMap = new LinkedList<Item>();
        for (Item item : Inv.list()) {
            itemMap.add(item.copy());
        }
        for (Item itemStats : itemMap) {
            MapleInventoryManipulator.removeFromSlot(c, invType, itemStats.getPosition(), itemStats.getQuantity(), true, false);
        }

        List<Item> sortedItems = sortItems(itemMap);
        for (Item item : sortedItems) {
            MapleInventoryManipulator.addFromDrop(c, item, false);
        }
        c.getSession().write(MaplePacketCreator.finishedGather(mode));
        c.getSession().write(MaplePacketCreator.enableActions());
        itemMap.clear();
        sortedItems.clear();
    }

    private static List<Item> sortItems(List<Item> passedMap) {
        List<Integer> itemIds = new ArrayList<Integer>();
        for (Item item : passedMap) {
            itemIds.add(Integer.valueOf(item.getItemId()));
        }
        Collections.sort(itemIds);

        List<Item> sortedList = new LinkedList<Item>();
        for (Integer val : itemIds) {
            for (Item item : passedMap) {
                if (val.intValue() == item.getItemId()) {
                    sortedList.add(item);
                    passedMap.remove(item);
                    break;
                }
            }
        }
        Integer val;
        return sortedList;
    }

    public static boolean UseRewardItem(byte slot, int itemId, MapleClient c, MapleCharacter chr) {
        Item toUse = c.getPlayer().getInventory(GameConstants.getInventoryType(itemId)).getItem((short) slot);
        c.getSession().write(MaplePacketCreator.enableActions());
        if ((toUse != null) && (toUse.getQuantity() >= 1) && (toUse.getItemId() == itemId) && (!chr.hasBlockedInventory())) {
            if ((chr.getInventory(MapleInventoryType.EQUIP).getNextFreeSlot() > -1) && (chr.getInventory(MapleInventoryType.USE).getNextFreeSlot() > -1) && (chr.getInventory(MapleInventoryType.SETUP).getNextFreeSlot() > -1) && (chr.getInventory(MapleInventoryType.ETC).getNextFreeSlot() > -1)) {
                MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
                if (itemId == 2028048) {
                    int mesars = 5000000;
                    if ((mesars > 0) && (chr.getMeso() < 2147483647 - mesars)) {
                        int gainmes = Randomizer.nextInt(mesars);
                        chr.gainMeso(gainmes, true, true);
                        c.getSession().write(MTSCSPacket.sendMesobagSuccess(gainmes));
                        MapleInventoryManipulator.removeById(c, GameConstants.getInventoryType(itemId), itemId, 1, false, false);
                        return true;
                    }
                    chr.dropMessage(1, "金币已达到上限无法使用这个道具.");
                    return false;
                }

                Pair<Integer, List<StructRewardItem>> rewards = ii.getRewardItem(itemId);
                if ((rewards != null) && (((Integer) rewards.getLeft()).intValue() > 0)) {
                    while (true) {
                        for (StructRewardItem reward : rewards.getRight()) {
                            if ((reward.prob > 0) && (Randomizer.nextInt(((Integer) rewards.getLeft()).intValue()) < reward.prob)) {
                                if (GameConstants.getInventoryType(reward.itemid) == MapleInventoryType.EQUIP) {
                                    Item item = ii.getEquipById(reward.itemid);
                                    if (reward.period > 0L) {
                                        item.setExpiration(System.currentTimeMillis() + reward.period * 60L * 60L * 10L);
                                    }
                                    item.setGMLog(new StringBuilder().append("Reward item: ").append(itemId).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                                    if (chr.isGM()) {
                                        chr.dropMessage(5, new StringBuilder().append("打开道具获得: ").append(item.getItemId()).toString());
                                    }
                                    MapleInventoryManipulator.addbyItem(c, item);
                                } else {
                                    if (chr.isGM()) {
                                        chr.dropMessage(5, new StringBuilder().append("打开道具获得: ").append(reward.itemid).append(" - ").append(reward.quantity).toString());
                                    }
                                    MapleInventoryManipulator.addById(c, reward.itemid, reward.quantity, new StringBuilder().append("Reward item: ").append(itemId).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                                }
                                MapleInventoryManipulator.removeById(c, GameConstants.getInventoryType(itemId), itemId, 1, false, false);

                                c.getSession().write(MaplePacketCreator.showRewardItemAnimation(reward.itemid, reward.effect));
                                chr.getMap().broadcastMessage(chr, MaplePacketCreator.showRewardItemAnimation(reward.itemid, reward.effect, chr.getId()), false);
                                return true;
                            }
                        }
                    }
                }
                chr.dropMessage(6, "出现未知错误.");
            } else {
                chr.dropMessage(6, "背包空间不足。");
            }
        }
        return false;
    }

    public static void UseItem(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        if ((chr == null) || (!chr.isAlive()) || (chr.getMapId() == 749040100) || (chr.getMap() == null) || (chr.hasDisease(MapleDisease.POTION)) || (chr.hasBlockedInventory()) || (chr.inPVP())) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        long time = System.currentTimeMillis();
        if (chr.getNextConsume() > time) {
            chr.dropMessage(5, "暂时无法使用这个道具，请稍后在试。");
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        c.getPlayer().updateTick(slea.readInt());
        byte slot = (byte) slea.readShort();
        int itemId = slea.readInt();
        Item toUse = chr.getInventory(MapleInventoryType.USE).getItem((short) slot);

        if ((toUse == null) || (toUse.getQuantity() < 1) || (toUse.getItemId() != itemId)) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }

        if (!FieldLimitType.PotionUse.check(chr.getMap().getFieldLimit())) {
            if (MapleItemInformationProvider.getInstance().getItemEffect(toUse.getItemId()).applyTo(chr)) {
                MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                if (chr.getMap().getConsumeItemCoolTime() > 0) {
                    chr.setNextConsume(time + chr.getMap().getConsumeItemCoolTime() * 1000);
                }
            }
        } else {
            c.getSession().write(MaplePacketCreator.enableActions());
        }
    }

    public static void UseCosmetic(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        if ((chr == null) || (!chr.isAlive()) || (chr.getMap() == null) || (chr.hasBlockedInventory()) || (chr.inPVP())) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        byte slot = (byte) slea.readShort();
        int itemId = slea.readInt();
        Item toUse = chr.getInventory(MapleInventoryType.USE).getItem((short) slot);

        if ((toUse == null) || (toUse.getQuantity() < 1) || (toUse.getItemId() != itemId) || (itemId / 10000 != 254) || (itemId / 1000 % 10 != chr.getGender())) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        if (MapleItemInformationProvider.getInstance().getItemEffect(toUse.getItemId()).applyTo(chr)) {
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
        }
    }

    public static void UseReturnScroll(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        if ((!chr.isAlive()) || (chr.getMapId() == 749040100) || (chr.hasBlockedInventory()) || (chr.isInBlockedMap()) || (chr.inPVP())) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        c.getPlayer().updateTick(slea.readInt());
        byte slot = (byte) slea.readShort();
        int itemId = slea.readInt();
        Item toUse = chr.getInventory(MapleInventoryType.USE).getItem((short) slot);
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        if ((toUse == null) || (toUse.getQuantity() < 1) || (toUse.getItemId() != itemId)) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        if (!FieldLimitType.PotionUse.check(chr.getMap().getFieldLimit())) {
            if (ii.getItemEffect(toUse.getItemId()).applyReturnScroll(chr)) {
                MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
            } else {
                c.getSession().write(MaplePacketCreator.enableActions());
            }
        } else {
            c.getSession().write(MaplePacketCreator.enableActions());
        }
    }

    public static void UseMagnify(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        chr.updateTick(slea.readInt());
        chr.setScrolledPosition((short) 0);
        byte src = (byte) slea.readShort();
        byte dst = (byte) slea.readShort();
        boolean insight = (src == 127) && (chr.getTrait(MapleTrait.MapleTraitType.sense).getLevel() >= 30);
        Item magnify = chr.getInventory(MapleInventoryType.USE).getItem((short) src);
        Equip toScroll;
        if (dst < 0) {
            toScroll = (Equip) chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) dst);
        } else {
            toScroll = (Equip) chr.getInventory(MapleInventoryType.EQUIP).getItem((short) dst);
        }

        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        int reqLevel = ii.getReqLevel(toScroll.getItemId()) / 10;
        int 鉴定需要金币 = 0;
        if (reqLevel >= 150) {
            鉴定需要金币 = reqLevel * 10000;
        } else if (reqLevel >= 120) {
            鉴定需要金币 = reqLevel * 5000;
        } else if (reqLevel >= 100) {
            鉴定需要金币 = reqLevel * 1000;
        } else if (reqLevel >= 90) {
            鉴定需要金币 = reqLevel * 500;
        } else if (reqLevel >= 80) {
            鉴定需要金币 = reqLevel * 400;
        } else if (reqLevel >= 70) {
            鉴定需要金币 = reqLevel * 300;
        } else if (reqLevel >= 60) {
            鉴定需要金币 = reqLevel * 200;
        } else if (reqLevel >= 50) {
            鉴定需要金币 = reqLevel * 100;
        } else if (reqLevel >= 40) {
            鉴定需要金币 = reqLevel * 80;
        } else if (reqLevel >= 30) {
            鉴定需要金币 = reqLevel * 60;
        } else if (reqLevel >= 20) {
            鉴定需要金币 = reqLevel * 40;
        } else if (reqLevel >= 10) {
            鉴定需要金币 = reqLevel * 20;
        } else {
            鉴定需要金币 = reqLevel;
        }

        boolean 金币是否足够鉴定需要数量 = c.getPlayer().getMeso() >= 鉴定需要金币;

        if (金币是否足够鉴定需要数量 == true) {
            insight = true;
        } else {
            if (!金币是否足够鉴定需要数量) {
                c.getPlayer().dropMessage(1, new StringBuilder().append(c.getPlayer().getVipname()).append("  您背包的金币不足  ").append(鉴定需要金币).append("\r\n无法鉴定： ").append(ii.getName(toScroll.getItemId())).append("  的潜能哦！\r\n想知道 ").append(ii.getName(toScroll.getItemId())).append(" 的神秘潜能就快点去赚钱吧！").toString());
                c.getSession().write(MaplePacketCreator.getInventoryFull());
                return;
            }
            if (((magnify == null) && (!insight)) || (toScroll == null) || (c.getPlayer().hasBlockedInventory())) {
                if (c.getPlayer().isLvkejian()) {
                    c.getPlayer().dropMessage(-11, new StringBuilder().append("magnify = ").append(magnify).append("    insight = ").append(insight).append("    toScroll = ").append(toScroll).append("   hasBlockedInventory = ").append(c.getPlayer().hasBlockedInventory()).toString());
                }
                c.getSession().write(MaplePacketCreator.getInventoryFull());
                return;
            }

        }

        if ((toScroll.getState() == 1) && ((insight) || (magnify.getItemId() == 2460003) || ((magnify.getItemId() == 2460002) && (reqLevel <= 12)) || ((magnify.getItemId() == 2460001) && (reqLevel <= 7)) || ((magnify.getItemId() == 2460000) && (reqLevel <= 3)))) {
            List pots = new LinkedList(ii.getAllPotentialInfo().values());

            int new_state1 = Math.abs(toScroll.getPotential1());
            int new_state2 = Math.abs(toScroll.getPotential2());
            int new_state3 = Math.abs(toScroll.getPotential3());

            int stateLines = c.getChannelServer().getStateLines();

            if ((new_state1 > 20) || (new_state1 < 17)) {
                new_state1 = 17;
            }
            if ((new_state2 > 20) || (new_state2 < 17)) {
                new_state2 = 17;
            }
            if (((new_state3 > 20) || (new_state3 < 17)) && (new_state3 != 0)) {
                new_state3 = 17;
            }

            int lines = 2;
            if (toScroll.getPotential3() != 0) {
                lines++;
            }
            if (toScroll.getPotential4() != 0) {
                lines++;
            }
            if (toScroll.getPotential5() != 0) {
                lines++;
            }
            if (lines > stateLines) {
                lines = stateLines;
            }
            String 消息 = new StringBuilder().append("潜能鉴定信息: 1 = ").append(new_state1).append(" 2 = ").append(new_state2).append(" 3 = ").append(new_state3).append("  ").toString();
            int 保护潜能位置 = toScroll.getBlockType();
            int 保护潜能id = toScroll.getBlockPotential();
            if (保护潜能位置 != 0) {
                switch (保护潜能位置) {
                    case 1:
                        toScroll.setPotential1(保护潜能id);
                        break;
                    case 2:
                        toScroll.setPotential2(保护潜能id);
                        break;
                    case 3:
                        toScroll.setPotential3(保护潜能id);
                }

                保护潜能位置 = 0;
                消息 = new StringBuilder().append(消息).append("保护潜能位置  ").append(保护潜能位置).append("  保护潜能id ").append(保护潜能id).toString();
            }
            toScroll.setBlockType(0);
            toScroll.setBlockPotential(0);
            boolean 鉴定潜能1成功 = false;
            while ((toScroll.取得潜能等级(1) != new_state1) && (lines >= 1) && (保护潜能位置 != 1) && (!鉴定潜能1成功)) {
                int 执行次数1 = 0;
                while (!鉴定潜能1成功) {
                    执行次数1++;
                    StructItemOption pot = (StructItemOption) ((List) pots.get(Randomizer.nextInt(pots.size()))).get(reqLevel);
                    if ((pot != null) && (pot.reqLevel / 10 <= reqLevel) && (GameConstants.optionTypeFits(pot.optionType, toScroll.getItemId())) && (GameConstants.optionTypeFitsX(pot.opID, toScroll.getItemId())) && (GameConstants.加载潜能是否符合潜能等级(pot.opID, new_state1))) {
                        toScroll.setPotential1(pot.opID);
                        鉴定潜能1成功 = true;
                    }

                    if (执行次数1 > 1000) {
                        toScroll.setPotential1(pot.opID);
                        鉴定潜能1成功 = true;
                    }
                }
                if ((toScroll.取得潜能等级(1) == new_state1) && (鉴定潜能1成功 == true)) {
                    消息 = new StringBuilder().append(消息).append(" 潜能1ID:").append(toScroll.getPotential1()).append(" 执行次数1: ").append(执行次数1).toString();
                }
            }
            boolean 鉴定潜能2成功 = false;
            while ((toScroll.取得潜能等级(2) != new_state2) && (stateLines >= 2) && (保护潜能位置 != 2) && (!鉴定潜能2成功)) {
                int 执行次数2 = 0;
                while (!鉴定潜能2成功) {
                    执行次数2++;
                    StructItemOption pot = (StructItemOption) ((List) pots.get(Randomizer.nextInt(pots.size()))).get(reqLevel);
                    if ((pot != null) && (pot.reqLevel / 10 <= reqLevel) && (GameConstants.optionTypeFits(pot.optionType, toScroll.getItemId())) && (GameConstants.optionTypeFitsX(pot.opID, toScroll.getItemId())) && (GameConstants.加载潜能是否符合潜能等级(pot.opID, new_state2))) {
                        toScroll.setPotential2(pot.opID);
                        鉴定潜能2成功 = true;
                    }

                    if (执行次数2 > 1000) {
                        toScroll.setPotential2(pot.opID);
                        鉴定潜能2成功 = true;
                    }
                }
                if ((toScroll.取得潜能等级(2) == new_state2) && (鉴定潜能2成功 == true)) {
                    消息 = new StringBuilder().append(消息).append("    潜能2ID:").append(toScroll.getPotential2()).append(" 执行次数2: ").append(执行次数2).toString();
                }
            }
            boolean 鉴定潜能3成功 = false;
            while ((toScroll.取得潜能等级(3) != new_state3) && (stateLines >= 3) && (new_state3 != 0) && (保护潜能位置 != 3) && (!鉴定潜能3成功)) {
                int 执行次数3 = 0;
                while (!鉴定潜能3成功) {
                    执行次数3++;
                    StructItemOption pot = (StructItemOption) ((List) pots.get(Randomizer.nextInt(pots.size()))).get(reqLevel);
                    if ((pot != null) && (pot.reqLevel / 10 <= reqLevel) && (GameConstants.optionTypeFits(pot.optionType, toScroll.getItemId())) && (GameConstants.optionTypeFitsX(pot.opID, toScroll.getItemId())) && (GameConstants.加载潜能是否符合潜能等级(pot.opID, new_state3))) {
                        toScroll.setPotential3(pot.opID);
                        鉴定潜能3成功 = true;
                    }

                    if (执行次数3 > 1000) {
                        toScroll.setPotential3(pot.opID);
                        鉴定潜能3成功 = true;
                    }
                }
                if ((toScroll.取得潜能等级(3) == new_state3) && (鉴定潜能3成功 == true)) {
                    消息 = new StringBuilder().append(消息).append("    潜能3ID:").append(toScroll.getPotential3()).append(" 执行次数3: ").append(执行次数3).toString();
                }

            }

            if (chr.isAdmin()) {
                chr.dropMessage(-11, 消息);
            }

            if ((toScroll.getState() >= 18) && (toScroll.getStateMsg() < 3)) {
                String medal = "";
                Item medalItem = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -26);
                if (medalItem != null) {
                    medal = new StringBuilder().append("<").append(ii.getName(medalItem.getItemId())).append("> ").toString();
                }
                if ((toScroll.getState() == 18) && (toScroll.getStateMsg() == 0)) {
                    toScroll.setStateMsg(1);
                    chr.finishAchievement(52);
                    if (!chr.isAdmin()) {
                        String msg = new StringBuilder().append(medal).append(chr.getName()).append(" : 鉴定出 A 级装备，大家祝贺他(她)吧！").toString();
                        Broadcast.broadcastSmega(MaplePacketCreator.喇叭_道具(msg, true, c.getChannel(), toScroll));
                    }
                } else if ((toScroll.getState() == 19) && (toScroll.getStateMsg() <= 1)) {
                    toScroll.setStateMsg(2);
                    chr.finishAchievement(53);
                    if (!chr.isAdmin()) {
                        String msg = new StringBuilder().append(medal).append(chr.getName()).append(" : 鉴定出 S 级装备，大家祝贺他(她)吧！").toString();
                        Broadcast.broadcastSmega(MaplePacketCreator.喇叭_道具(msg, true, c.getChannel(), toScroll));
                    }
                } else if ((toScroll.getState() == 20) && (toScroll.getStateMsg() <= 3)) {
                    toScroll.setStateMsg(3);
                    chr.finishAchievement(54);
                    if (!chr.isAdmin()) {
                        String msg = new StringBuilder().append(medal).append(chr.getName()).append(" : 鉴定出 SS 级装备，大家祝贺他(她)吧！").toString();
                        Broadcast.broadcastSmega(MaplePacketCreator.喇叭_道具(msg, true, c.getChannel(), toScroll));
                    }
                }
            }
            chr.getTrait(MapleTrait.MapleTraitType.insight).addExp((insight ? 10 : magnify.getItemId() + 2 - 2460000) * 2, chr);
            chr.getMap().broadcastMessage(MaplePacketCreator.放大镜效果(chr.getId(), toScroll.getPosition()));
            chr.gainMeso(-鉴定需要金币, true);
            if (!insight) {
                c.getSession().write(MaplePacketCreator.scrolledItem(magnify, toScroll, false, dst < 0));
                MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, magnify.getPosition(), (short) 1, false);
            } else {
                chr.forceReAddItem(toScroll, MapleInventoryType.EQUIP);
            }
            c.getSession().write(MaplePacketCreator.enableActions());
        } else {
            if (c.getPlayer().isLvkejian()) {
                c.getPlayer().dropMessage(-11, new StringBuilder().append("toScroll.getState() = ").append(toScroll.getState()).append("    magnify.getItemId() = ").append(magnify.getItemId()).append("    reqLevel = ").append(reqLevel).append("   hasBlockedInventory = ").append(c.getPlayer().hasBlockedInventory()).toString());
            }

            c.getSession().write(MaplePacketCreator.getInventoryFull());
        }
    }

    public static void 重置附加潜能(MapleClient c, int dst, boolean 魔方, boolean 开放三潜能) {
        Equip 装备 = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((short) dst);
        int 附加潜能1等级 = 装备.取得潜能等级(4);
        int 附加潜能2等级 = 装备.取得潜能等级(5);
        int 附加潜能3等级 = 装备.取得潜能等级(6);

        if (魔方) {
            if (Randomizer.nextInt(200) < 1) {
                附加潜能1等级 = 20;
                附加潜能2等级 = 20;
                附加潜能3等级 = 20;
            } else if (Randomizer.nextInt(100) < 2) {
                附加潜能1等级 = 19;
                附加潜能2等级 = 19;
                附加潜能3等级 = 19;
            } else if (Randomizer.nextInt(100) < 5) {
                附加潜能1等级 = 18;
                附加潜能2等级 = 18;
                附加潜能3等级 = 18;
            } else {
                if (Randomizer.nextInt(100) < 15) {
                    附加潜能1等级++;
                }
                if (Randomizer.nextInt(100) < 5) {
                    附加潜能2等级++;
                }
                if ((Randomizer.nextInt(100) < 10) && (附加潜能3等级 != 0)) {
                    附加潜能3等级++;
                }
            }
            if (附加潜能1等级 < 装备.取得潜能等级(4)) {
                附加潜能1等级 = 装备.取得潜能等级(4);
            }
            if (附加潜能2等级 < 装备.取得潜能等级(5)) {
                附加潜能2等级 = 装备.取得潜能等级(5);
            }
            if (附加潜能3等级 < 装备.取得潜能等级(6)) {
                附加潜能3等级 = 装备.取得潜能等级(6);
            }
        }
        if ((附加潜能1等级 > 20) || (附加潜能1等级 < 17)) {
            附加潜能1等级 = 17;
        }
        if ((附加潜能2等级 > 20) || (附加潜能2等级 < 17)) {
            附加潜能2等级 = 17;
        }
        if (((附加潜能3等级 > 20) || (附加潜能3等级 < 17)) && ((附加潜能3等级 != 0) || (开放三潜能 == true))) {
            附加潜能3等级 = 17;
        }

        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        int reqLevel = ii.getReqLevel(装备.getItemId()) / 10;

        List pots = new LinkedList(ii.getAllPotentialInfo().values());

        String 消息 = "重置附加潜能信息:";
        boolean 鉴定潜能4成功 = false;
        while (((装备.取得潜能等级(4) != 附加潜能1等级) || (魔方 == true)) && (!鉴定潜能4成功)) {
            int 执行次数4 = 0;
            while (!鉴定潜能4成功) {
                执行次数4++;
                StructItemOption pot = (StructItemOption) ((List) pots.get(Randomizer.nextInt(pots.size()))).get(reqLevel);
                if ((pot != null) && (pot.reqLevel / 10 <= reqLevel) && (GameConstants.optionTypeFits(pot.optionType, 装备.getItemId())) && (GameConstants.optionTypeFitsX(pot.opID, 装备.getItemId())) && (GameConstants.加载潜能是否符合潜能等级(pot.opID, 附加潜能1等级)) && (pot.opID < 60000)) {
                    装备.setPotential4(pot.opID);
                    鉴定潜能4成功 = true;
                }

                if (执行次数4 > 1000) {
                    装备.setPotential4(pot.opID);
                    鉴定潜能4成功 = true;
                }
            }
            if ((装备.取得潜能等级(4) == 附加潜能1等级) && (鉴定潜能4成功 == true)) {
                消息 = new StringBuilder().append(消息).append("    潜能4ID:").append(装备.getPotential4()).append(" 执行次数4: ").append(执行次数4).toString();
            }
        }
        boolean 鉴定潜能5成功 = false;
        while (((装备.取得潜能等级(5) != 附加潜能2等级) || (魔方 == true)) && (!鉴定潜能5成功)) {
            int 执行次数5 = 0;
            while (!鉴定潜能5成功) {
                执行次数5++;
                StructItemOption pot = (StructItemOption) ((List) pots.get(Randomizer.nextInt(pots.size()))).get(reqLevel);
                if ((pot != null) && (pot.reqLevel / 10 <= reqLevel) && (GameConstants.optionTypeFits(pot.optionType, 装备.getItemId())) && (GameConstants.optionTypeFitsX(pot.opID, 装备.getItemId())) && (GameConstants.加载潜能是否符合潜能等级(pot.opID, 附加潜能2等级)) && (pot.opID < 60000)) {
                    装备.setPotential5(pot.opID);
                    鉴定潜能5成功 = true;
                }

                if (执行次数5 > 60010) {
                    装备.setPotential5(pot.opID);
                    鉴定潜能5成功 = true;
                }
            }
            if ((装备.取得潜能等级(5) == 附加潜能2等级) && (鉴定潜能5成功 == true)) {
                消息 = new StringBuilder().append(消息).append("    潜能5ID:").append(装备.getPotential5()).append(" 执行次数5: ").append(执行次数5).toString();
            }
        }
        boolean 鉴定潜能6成功 = false;
        while (((装备.取得潜能等级(6) != 附加潜能3等级) || (魔方 == true)) && (附加潜能3等级 > 0) && (!鉴定潜能6成功)) {
            int 执行次数6 = 0;
            while (!鉴定潜能6成功) {
                执行次数6++;
                StructItemOption pot = (StructItemOption) ((List) pots.get(Randomizer.nextInt(pots.size()))).get(reqLevel);
                if ((pot != null) && (pot.reqLevel / 10 <= reqLevel) && (GameConstants.optionTypeFits(pot.optionType, 装备.getItemId())) && (GameConstants.optionTypeFitsX(pot.opID, 装备.getItemId())) && (GameConstants.加载潜能是否符合潜能等级(pot.opID, 附加潜能3等级)) && (pot.opID < 60000)) {
                    装备.setPotential6(pot.opID);
                    鉴定潜能6成功 = true;
                }

                if (执行次数6 > 60010) {
                    装备.setPotential6(pot.opID);
                    鉴定潜能6成功 = true;
                }
            }
            if ((装备.取得潜能等级(6) == 附加潜能3等级) && (鉴定潜能6成功 == true)) {
                消息 = new StringBuilder().append(消息).append("    潜能6ID:").append(装备.getPotential6()).append(" 执行次数6: ").append(执行次数6).toString();
            }
        }
        c.getPlayer().forceReAddItem(装备, MapleInventoryType.EQUIP);
        c.getSession().write(MaplePacketCreator.enableActions());
        if (c.getPlayer().isAdmin()) {
            c.getPlayer().dropMessage(-11, 消息);
        }
        String medal = "";
        Item medalItem = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short) -26);
        if (medalItem != null) {
            medal = new StringBuilder().append("<").append(ii.getName(medalItem.getItemId())).append("> ").toString();
        }
        String msg = new StringBuilder().append(medal).append(c.getPlayer().getName()).append(" : 重置装备附加潜能成功，大家恭喜他(她)吧！").toString();
        Broadcast.broadcastSmega(MaplePacketCreator.喇叭_道具(msg, true, c.getChannel(), 装备));
    }

    public static void addToScrollLog(int accountID, int charID, int scrollID, int itemID, byte oldSlots, byte newSlots, byte viciousHammer, String result, boolean ws, boolean ls, int vega) {
        try {
            PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO scroll_log VALUES(DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
            ps.setInt(1, accountID);
            ps.setInt(2, charID);
            ps.setInt(3, scrollID);
            ps.setInt(4, itemID);
            ps.setByte(5, oldSlots);
            ps.setByte(6, newSlots);
            ps.setByte(7, viciousHammer);
            ps.setString(8, result);
            ps.setByte(9, (byte) (ws ? 1 : 0));
            ps.setByte(10, (byte) (ls ? 1 : 0));
            ps.setInt(11, vega);
            ps.execute();
            ps.close();
        } catch (SQLException e) {
            FileoutputUtil.outputFileError("log\\Packet_Except.log", e);
        }
    }

    public static void 附加潜能操作(short 使用卷轴所在位置, short 附加装备所在位置, MapleClient c, MapleCharacter chr) {
        boolean 新砸卷对话框 = false;
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        chr.setScrolledPosition((short) 0);

        if (附加装备所在位置 < 0) {
            chr.dropMessage(1, "该物品不支持这样使用，请使用快捷砸卷进行！");
            chr.getClient().getSession().write(MaplePacketCreator.enableActions());
            return;
        }

        新砸卷对话框 = true;
        Equip 装备 = (Equip) chr.getInventory(MapleInventoryType.EQUIP).getItem(附加装备所在位置);

        if (chr.isAdmin()) {
            chr.dropMessage(-9, new StringBuilder().append("开始为装备附加潜能  附加装备所在位置 = ").append(附加装备所在位置).toString());
        }
        Item scroll = chr.getInventory(MapleInventoryType.USE).getItem(使用卷轴所在位置);
        if (scroll == null) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, "砸卷错误: scroll == null");
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return;
        }
        if (chr.isAdmin()) {
           chr.dropMessage(-9, new StringBuilder().append("附加潜能卷信息: 卷轴ID ").append(scroll.getItemId()).append(" 卷轴名字 ").append(ii.getName(scroll.getItemId())).toString());
        }
        if (GameConstants.is附加潜能附加卷轴(scroll.getItemId())) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, "砸卷错误: !isTablet ----- 附加");
            }
            if ((装备.getPotential4() != 0) || (装备.getPotential5() != 0) || (装备.getPotential6() != 0)) {
                chr.dropMessage(1, new StringBuilder().append("当前装备已经拥有附加潜能！").toString());
                c.getSession().write(MaplePacketCreator.getInventoryFull());
                return;
            }
            boolean 是否成功 = true;
            int 成功率 = GameConstants.附加潜能附加卷轴成功率(scroll.getItemId());
            if (Randomizer.nextInt(100) <= 成功率) {
                重置附加潜能(c, 附加装备所在位置, false, 成功率 == 100);
                c.getSession().write(MaplePacketCreator.scrolledItem(scroll, 装备, false, 附加装备所在位置 < 0));
                chr.getMap().broadcastMessage(chr, MaplePacketCreator.getScrollEffect(chr.getId(), Equip.ScrollResult.成功, false, false, scroll.getItemId(), 装备.getItemId()), true);
            } else {
                是否成功 = false;
                boolean 装备是否损坏 = false;
                c.getPlayer().dropMessage(-11, "附加潜能失败！");
                c.getPlayer().dropMessage(-1, "附加潜能失败！");
                short oldFlag = 装备.getFlag();
                Equip.ScrollResult scrollSuccess;
                if (ItemFlag.防爆卷轴.check(oldFlag)) {
                    scrollSuccess = Equip.ScrollResult.失败;
                    装备.setFlag((short) (oldFlag - ItemFlag.防爆卷轴.getValue()));
                } else {
                    scrollSuccess = Equip.ScrollResult.消失;
                    装备是否损坏 = true;
                }
                c.getSession().write(MaplePacketCreator.getInventoryFull());
                chr.getMap().broadcastMessage(chr, MaplePacketCreator.getScrollEffect(chr.getId(), Equip.ScrollResult.失败, false, false, scroll.getItemId(), 装备.getItemId()), true);
                if (scrollSuccess == Equip.ScrollResult.消失) {
                    if (附加装备所在位置 < 0) {
                        chr.getInventory(MapleInventoryType.EQUIPPED).removeItem(装备.getPosition());
                    } else {
                        chr.getInventory(MapleInventoryType.EQUIP).removeItem(装备.getPosition());
                    }
                } else {
                    chr.setScrolledPosition(装备.getPosition());
                    c.getSession().write(MaplePacketCreator.pamSongUI());
                }
                c.getSession().write(MaplePacketCreator.scrolledItem(scroll, 装备, 装备是否损坏, 附加装备所在位置 < 0));
            }
            if (新砸卷对话框 == true);
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, scroll.getPosition(), (short) 1, false);
        }

        if (附加装备所在位置 < 0) {
            chr.equipChanged();
        }
    }

    public static boolean UseUpgradeScroll(short slot, short dst, short ws, MapleClient c, MapleCharacter chr, boolean cash) {
        return UseUpgradeScroll(slot, dst, ws, c, chr, 0, cash);
    }

    public static boolean UseUpgradeScroll(short slot, short dst, short ws, MapleClient c, MapleCharacter chr, int vegas, boolean cash) {
        boolean whiteScroll = false;
        boolean legendarySpirit = false;
        boolean 新砸卷对话框 = false;
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        chr.setScrolledPosition((short) 0);
        if ((ws & 0x2) == 2) {
            whiteScroll = true;
        }
        Equip toScroll;
        if (dst < 0) {
            toScroll = (Equip) chr.getInventory(MapleInventoryType.EQUIPPED).getItem(dst);
        } else {
            新砸卷对话框 = true;
            toScroll = (Equip) chr.getInventory(MapleInventoryType.EQUIP).getItem(dst);
        }

        if (chr.isAdmin()) {
            chr.dropMessage(-9, new StringBuilder().append("开始砸卷  dst = ").append(dst).toString());
        }
        if ((toScroll == null) || (c.getPlayer().hasBlockedInventory())) {
            chr.dropMessage(-9, new StringBuilder().append("砸卷错误: toScroll == ").append(toScroll).append("   c.getPlayer().hasBlockedInventory() = ").append(c.getPlayer().hasBlockedInventory()).toString());
            return false;
        }
        byte oldLevel = toScroll.getLevel();
        byte oldEnhance = toScroll.getEnhance();
        byte oldState = toScroll.getState();
        short oldFlag = toScroll.getFlag();
        byte oldSlots = toScroll.getUpgradeSlots();
        byte oldVH = toScroll.getViciousHammer();
        int itemID = toScroll.getItemId();
        Item scroll;
        if (cash) {
            scroll = chr.getInventory(MapleInventoryType.CASH).getItem(slot);
        } else {
            scroll = chr.getInventory(MapleInventoryType.USE).getItem(slot);
        }
        if (scroll == null) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, "砸卷错误: scroll == null");
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }
        if (chr.isAdmin()) {
            chr.dropMessage(-9, new StringBuilder().append("1砸卷信息: 卷轴ID ").append(scroll.getItemId()).append(" 卷轴名字 ").append(ii.getName(scroll.getItemId())).toString());
        }
        if ((!GameConstants.is特殊卷轴(scroll.getItemId())) && (!GameConstants.is白医卷轴(scroll.getItemId())) && (!GameConstants.is强化卷轴(scroll.getItemId())) && (!GameConstants.is潜能卷轴(scroll.getItemId())) && (!GameConstants.is突破上限之石(scroll.getItemId()))) {
            if (toScroll.getUpgradeSlots() < 1) {
                chr.dropMessage(1, new StringBuilder().append("当前装备可升级次数为: ").append(toScroll.getUpgradeSlots()).toString());
                c.getSession().write(MaplePacketCreator.getInventoryFull());
                return false;
            }
        } else if (GameConstants.is强化卷轴(scroll.getItemId())) {
            if ((toScroll.getUpgradeSlots() >= 1) || (toScroll.getEnhance() >= 100) || (vegas > 0) || (ii.isCash(toScroll.getItemId()))) {
                if (chr.isAdmin()) {
                    chr.dropMessage(-9, new StringBuilder().append("砸卷错误: 装备强化检测： isEquipScroll ").append(toScroll.getUpgradeSlots() >= 1).append(" ").append(toScroll.getEnhance() >= 100).append(" ").append(vegas > 0).append(" ").append(ii.isCash(toScroll.getItemId())).toString());
                }
                c.getSession().write(MaplePacketCreator.getInventoryFull());
                return false;
            }
        } else if (GameConstants.is潜能卷轴(scroll.getItemId())) {
            boolean isA级潜能卷轴 = scroll.getItemId() / 100 == 20497;
            boolean is军团盾 = (toScroll.getItemId() >= 1099000) && (toScroll.getItemId() <= 1099004);
            boolean is箭矢卡片 = toScroll.getItemId() / 10000 == 135;
            if (((!isA级潜能卷轴) && (toScroll.getState() >= 1)) || ((isA级潜能卷轴) && (toScroll.getState() >= 18)) || ((toScroll.getLevel() == 0) && (toScroll.getUpgradeSlots() == 0) && (!is箭矢卡片) && (!isA级潜能卷轴) && (!is军团盾)) || (vegas > 0) || (ii.isCash(toScroll.getItemId()))) {
                if (chr.isAdmin()) {
                    chr.dropMessage(-9, new StringBuilder().append("砸卷错误: isPotentialScroll ").append(toScroll.getState() >= 1).append(" ").append((toScroll.getLevel() == 0) && (toScroll.getUpgradeSlots() == 0) && (!is箭矢卡片) && (!isA级潜能卷轴) && (!is军团盾)).append(" ").append(vegas > 0).append(" ").append(ii.isCash(toScroll.getItemId())).toString());
                }
                c.getSession().write(MaplePacketCreator.getInventoryFull());
                return false;
            }
        } else if ((GameConstants.is特殊卷轴(scroll.getItemId())) && ((ii.isCash(toScroll.getItemId())) || (toScroll.getEnhance() >= 12))) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, new StringBuilder().append("砸卷错误: isSpecialScroll isCash - ").append(ii.isCash(toScroll.getItemId())).append(" getEnhance - ").append(toScroll.getEnhance() >= 12).toString());
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }

        if ((!GameConstants.canScroll(toScroll.getItemId())) && (!GameConstants.is枫叶卷轴(toScroll.getItemId()))) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, new StringBuilder().append("砸卷错误: !canScroll ").append(!GameConstants.canScroll(toScroll.getItemId())).append(" !isChaosScroll ").append(!GameConstants.is枫叶卷轴(toScroll.getItemId())).toString());
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }
        if (((GameConstants.is白医卷轴(scroll.getItemId())) || (GameConstants.is饰品制炼书(scroll.getItemId())) || (GameConstants.is周年庆卷轴(scroll.getItemId())) || (GameConstants.is枫叶卷轴(scroll.getItemId()))) && ((vegas > 0) || (ii.isCash(toScroll.getItemId())))) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, new StringBuilder().append("砸卷错误: isCleanSlate ").append(GameConstants.is白医卷轴(scroll.getItemId())).append(" isTablet ").append(GameConstants.is饰品制炼书(scroll.getItemId())).toString());
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }
        if ((GameConstants.is饰品制炼书(scroll.getItemId())) && (toScroll.getDurability() < 0)) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, new StringBuilder().append("砸卷错误: isTablet ").append(GameConstants.is饰品制炼书(scroll.getItemId())).append(" getDurability ").append(toScroll.getDurability() < 0).toString());
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }
        if ((!GameConstants.is饰品制炼书(scroll.getItemId())) && (!GameConstants.is潜能卷轴(scroll.getItemId()))&&(!GameConstants.is附加潜能附加卷轴(scroll.getItemId())) && (!GameConstants.is强化卷轴(scroll.getItemId())) && (!GameConstants.is周年庆卷轴(scroll.getItemId())) && (!GameConstants.is白医卷轴(scroll.getItemId())) && (!GameConstants.is特殊卷轴(scroll.getItemId())) && (!GameConstants.is枫叶卷轴(scroll.getItemId())) && (toScroll.getDurability() >= 0)) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, "砸卷错误: !isTablet ----- 1");
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }
        Item wscroll = null;

        List scrollReqs = ii.getScrollReqs(scroll.getItemId());
        if ((scrollReqs != null) && (scrollReqs.size() > 0) && (!scrollReqs.contains(Integer.valueOf(toScroll.getItemId())))) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, "砸卷错误: scrollReqs != null && scrollReqs.size() > 0 && !scrollReqs.contains(toScroll.getItemId())");
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }
        if (whiteScroll) {
            wscroll = chr.getInventory(MapleInventoryType.USE).findById(2340000);
            if (wscroll == null) {
                if (chr.isAdmin()) {
                    chr.dropMessage(-9, "砸卷错误: wscroll == null");
                }
                c.getSession().write(MaplePacketCreator.getInventoryFull());
                whiteScroll = false;
            }
        }

        if (((GameConstants.is饰品制炼书(scroll.getItemId())) || (GameConstants.is周年庆卷轴(scroll.getItemId()))) && (!GameConstants.is宿命卷轴(scroll.getItemId()))) {
            switch (scroll.getItemId() % 100 / 100) {
                case 0:
                    if ((GameConstants.isTwoHanded(toScroll.getItemId())) || (!GameConstants.isWeapon(toScroll.getItemId()))) {
                        if (chr.isAdmin()) {
                            chr.dropMessage(-9, " 饰品制炼书 (周年庆卷轴) (scroll.getItemId() % 1000 / 100) 砸卷错误: 最后检测 ---  卷轴类型 0");
                        }
                        c.getSession().write(MaplePacketCreator.getInventoryFull());
                        return false;
                    }
                    break;
                case 1:
                    if ((!GameConstants.isTwoHanded(toScroll.getItemId())) || (!GameConstants.isWeapon(toScroll.getItemId()))) {
                        if (chr.isAdmin()) {
                            chr.dropMessage(-9, "饰品制炼书 (周年庆卷轴) (scroll.getItemId() % 1000 / 100) 砸卷错误: 最后检测 --- 1");
                        }
                        c.getSession().write(MaplePacketCreator.getInventoryFull());
                        return false;
                    }
                    break;
                case 2:
                    if ((GameConstants.isAccessory(toScroll.getItemId())) || (GameConstants.isWeapon(toScroll.getItemId()))) {
                        if (chr.isAdmin()) {
                            chr.dropMessage(-9, "饰品制炼书 (周年庆卷轴) (scroll.getItemId() % 1000 / 100) 砸卷错误: 最后检测 --- 2");
                        }
                        c.getSession().write(MaplePacketCreator.getInventoryFull());
                        return false;
                    }
                    break;
                case 3:
                    if ((!GameConstants.isAccessory(toScroll.getItemId())) || (GameConstants.isWeapon(toScroll.getItemId()))) {
                        if (chr.isAdmin()) {
                            chr.dropMessage(-9, "饰品制炼书 (周年庆卷轴) (scroll.getItemId() % 1000 / 100) 砸卷错误: 最后检测 --- 3");
                        }
                        c.getSession().write(MaplePacketCreator.getInventoryFull());
                        return false;
                    }
                    break;
            }
        } else if ((!GameConstants.is突破上限之石(scroll.getItemId())) && (!GameConstants.is星火卷轴(scroll.getItemId())) && (!GameConstants.is配饰卷轴(scroll.getItemId())) && (!GameConstants.is枫叶卷轴(scroll.getItemId())) && (!GameConstants.is白医卷轴(scroll.getItemId())) && (!GameConstants.is强化卷轴(scroll.getItemId())) && (!GameConstants.is周年庆卷轴(scroll.getItemId())) && (!GameConstants.is宿命卷轴(scroll.getItemId())) && (!GameConstants.is潜能卷轴(scroll.getItemId()))&& (!GameConstants.is特殊卷轴(scroll.getItemId())) && (!ii.canScroll(scroll.getItemId(), toScroll.getItemId()))) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, "砸卷错误: 最后检测 --- 4");
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }

        if ((GameConstants.is配饰卷轴(scroll.getItemId())) && (!GameConstants.isAccessory(toScroll.getItemId()))) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, "砸卷错误: 最后检测 --- 5");
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }
        if (scroll.getQuantity() <= 0) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, "砸卷错误: 最后检测 --- 6");
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }
        if ((legendarySpirit) && (vegas == 0) && (chr.getSkillLevel(SkillFactory.getSkill(PlayerStats.getSkillByJob(1003, chr.getJob()))) <= 0)) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, new StringBuilder().append("砸卷错误: 最后检测 --- 7   legendarySpirit = ").append(legendarySpirit).append("    vegas = ").append(vegas).append("").append("chr.getSkillLevel(SkillFactory.getSkill(PlayerStats.getSkillByJob(1003, chr.getJob()))) = ").append(chr.getSkillLevel(SkillFactory.getSkill(PlayerStats.getSkillByJob(1003, chr.getJob())))).toString());
            }

            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return false;
        }

        if ((chr.getInventory(MapleInventoryType.USE).findById(2340000) != null) && (ws == 2) && (!GameConstants.is强化卷轴(scroll.getItemId())) && (!GameConstants.is特殊卷轴(scroll.getItemId())) && (!GameConstants.is潜能卷轴(scroll.getItemId())) &&(!GameConstants.is附加潜能附加卷轴(scroll.getItemId()))&& (!GameConstants.is白医卷轴(scroll.getItemId())) && (!GameConstants.is突破上限之石(scroll.getItemId())) && (!GameConstants.is白医卷轴(scroll.getItemId())) && (!GameConstants.is周年庆卷轴(scroll.getItemId())) && (!GameConstants.is宿命卷轴(scroll.getItemId())) && (!GameConstants.is星火卷轴(scroll.getItemId())) && (!GameConstants.is必成卷轴(scroll.getItemId()))) {
            whiteScroll = true;
        }
        int 砸卷前武器突破上限值 = toScroll.getMaxDamage();

        if (chr.isLvkejian()) {
            chr.dropMessage(-11, new StringBuilder().append("是否使用 whiteScroll = ").append(whiteScroll).toString());
        }

        Equip scrolled = (Equip) ii.scrollEquipWithId(toScroll, scroll, whiteScroll, chr, vegas);

        Equip scrolleds = null;
        boolean is神之子_武器强化 = false;
        if ((GameConstants.is神之子(chr.getJob())) && ((GameConstants.is神之子_贝塔_武器(toScroll.getItemId())) || (GameConstants.is神之子_阿尔法_武器(toScroll.getItemId())))) {
            Equip 阿尔法武器 = toScroll = (Equip) chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) (dst == -10 ? -11 : -10));
            scrolleds = (Equip) ii.scrollEquipWithId(阿尔法武器, scroll, whiteScroll, chr, vegas);
            is神之子_武器强化 = true;
        }

        boolean 是否成功 = true;
        Equip.ScrollResult scrollSuccess;
        if ((scrolled == null) && ((GameConstants.is强化卷轴(scroll.getItemId())) || (GameConstants.is周年庆卷轴(scroll.getItemId())) ||(!GameConstants.is附加潜能附加卷轴(scroll.getItemId())) ||(GameConstants.is潜能卷轴(scroll.getItemId())))) {
            if (ItemFlag.防爆卷轴.check(oldFlag)) {
                scrolled = toScroll;
                scrollSuccess = Equip.ScrollResult.失败;
                scrolled.setFlag((short) (oldFlag - ItemFlag.防爆卷轴.getValue()));
            } else {
                if ((GameConstants.is神之子_贝塔_武器(toScroll.getItemId())) || (GameConstants.is神之子_阿尔法_武器(toScroll.getItemId()))) {
                    scrollSuccess = Equip.ScrollResult.失败;
                } else {
                    scrollSuccess = Equip.ScrollResult.消失;
                }
            }
            是否成功 = false;
        } else if (scrolled == null) {
            if (ItemFlag.防爆卷轴.check(oldFlag)) {
                scrolled = toScroll;
                scrollSuccess = Equip.ScrollResult.失败;
                scrolled.setFlag((short) (oldFlag - ItemFlag.防爆卷轴.getValue()));
            } else {
                if ((GameConstants.is神之子_贝塔_武器(toScroll.getItemId())) || (GameConstants.is神之子_阿尔法_武器(toScroll.getItemId()))) {
                    scrollSuccess = Equip.ScrollResult.失败;
                } else {
                    scrollSuccess = Equip.ScrollResult.失败;
                    String mms = new StringBuilder().append("砸卷失败！该卷轴的数据未添加，请联系六月修正！卷轴ID：").append(scroll.getItemId()).toString();
                    c.getPlayer().dropMessage(-11, mms);
                    c.getPlayer().dropMessage(25, mms);
                }
            }
            if (c.getPlayer().isLvkejian()) {
                c.getPlayer().dropMessage(-11, "砸卷 失败！ scrolled == null ");
            }
            是否成功 = false;
        } else {
            if (((scroll.getItemId() / 100 == 20497) && (scrolled.getState() == 1)) || (scrolled.getLevel() > oldLevel) || (scrolled.getEnhance() > oldEnhance) || (scrolled.getState() > oldState) || (scrolled.getFlag() > oldFlag)) {
                scrollSuccess = Equip.ScrollResult.成功;
            } else if (GameConstants.is突破上限之石(scroll.getItemId())) {
                if (砸卷前武器突破上限值 < toScroll.getMaxDamage()) {
                    scrollSuccess = Equip.ScrollResult.成功;
                } else {
                    scrollSuccess = Equip.ScrollResult.失败;
                    是否成功 = false;
                }
            } else {
                if ((GameConstants.is白医卷轴(scroll.getItemId())) && (scrolled.getUpgradeSlots() > oldSlots)) {
                    scrollSuccess = Equip.ScrollResult.成功;
                } else {
                    scrollSuccess = Equip.ScrollResult.失败;
                    是否成功 = false;
                }
            }
        }

        if (ItemFlag.防护卷轴.check(oldFlag)) {
            if (scrolled != null) {
                scrolled.setFlag((short) (scrolled.getFlag() - ItemFlag.防护卷轴.getValue()));
            }
        } else {
            chr.getInventory(GameConstants.getInventoryType(scroll.getItemId())).removeItem(scroll.getPosition(), (short) 1, false);
        }
        if (whiteScroll) {
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, wscroll.getPosition(), (short) 1, false, false);
        } else if ((scrollSuccess == Equip.ScrollResult.失败) && (scrolled.getUpgradeSlots() < oldSlots) && (chr.getInventory(MapleInventoryType.CASH).findById(5640000) != null)) {
            chr.setScrolledPosition(scrolled.getPosition());
            if (vegas == 0) {
                c.getSession().write(MaplePacketCreator.pamSongUI());
            }
        }
        if (scrollSuccess == Equip.ScrollResult.消失) {
            c.getSession().write(MaplePacketCreator.scrolledItem(scroll, toScroll, true, dst < 0));

            if (dst < 0) {
                chr.getInventory(MapleInventoryType.EQUIPPED).removeItem(toScroll.getPosition());
            } else {
                chr.getInventory(MapleInventoryType.EQUIP).removeItem(toScroll.getPosition());
            }
        } else if (vegas == 0) {
            c.getSession().write(MaplePacketCreator.scrolledItem(scroll, scrolled, false, dst < 0));
            if ((is神之子_武器强化 == true) && (scrolleds != null)) {
                c.getSession().write(MaplePacketCreator.scrolledItem(scroll, scrolleds, false, dst < 0));
                c.getPlayer().set神之子_zero_zj_dst(0);
                c.getPlayer().set神之子_zero_zj_slot(0);
            }

        }

        chr.getMap().broadcastMessage(chr, MaplePacketCreator.getScrollEffect(chr.getId(), scrollSuccess, legendarySpirit, whiteScroll, scroll.getItemId(), toScroll.getItemId()), (新砸卷对话框 != true)
                || (vegas == 0));

        if ((dst < 0) && ((scrollSuccess == Equip.ScrollResult.成功) || (scrollSuccess == Equip.ScrollResult.消失)) && (vegas == 0)) {
            chr.equipChanged();
        }
        chr.getClient().getSession().write(MaplePacketCreator.enableActions());
        return true;
    }

    public static boolean UseSkillBook(byte slot, int itemId, MapleClient c, MapleCharacter chr) {
        if (itemId == 2290285) {
            int itemid = Randomizer.nextInt(373) + 2290000;
            if ((!MapleItemInformationProvider.getInstance().itemExists(itemid)) || (MapleItemInformationProvider.getInstance().getName(itemid).contains("Special")) || (MapleItemInformationProvider.getInstance().getName(itemid).contains("Event"))) {
                return false;
            }
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            if (!ii.itemExists(itemid)) {
                c.getPlayer().dropMessage(5, new StringBuilder().append(itemId).append(" 这个道具不存在.").toString());
                return false;
            }
            Item toUse = chr.getInventory(GameConstants.getInventoryType(itemId)).getItem((short) slot);
            MapleInventoryManipulator.addById(c, itemid, (short) 1, new StringBuilder().append("Reward item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
            return true;
        }

        Item toUse = chr.getInventory(GameConstants.getInventoryType(itemId)).getItem((short) slot);
        if ((toUse == null) || (toUse.getQuantity() < 1) || (toUse.getItemId() != itemId) || (chr.hasBlockedInventory())) {
            return false;
        }
        Map skilldata = MapleItemInformationProvider.getInstance().getEquipStats(toUse.getItemId());
        if (skilldata == null) {
            return false;
        }
        boolean canuse = false;
        boolean success = false;
        int skill = 0;
        int maxlevel = 0;

        Integer SuccessRate = (Integer) skilldata.get("success");
        Integer ReqSkillLevel = (Integer) skilldata.get("reqSkillLevel");
        Integer MasterLevel = (Integer) skilldata.get("masterLevel");

        byte i = 0;
        while (true) {
            Integer CurrentLoopedSkillId = (Integer) skilldata.get(new StringBuilder().append("skillid").append(i).toString());
            i = (byte) (i + 1);
            if ((CurrentLoopedSkillId == null) || (MasterLevel == null)) {
                break;
            }
            Skill CurrSkillData = SkillFactory.getSkill(CurrentLoopedSkillId.intValue());
            if ((CurrSkillData != null) && (CurrSkillData.canBeLearnedBy(chr.getJob())) && ((ReqSkillLevel == null) || (chr.getSkillLevel(CurrSkillData) >= ReqSkillLevel.intValue())) && (chr.getMasterLevel(CurrSkillData) < MasterLevel.intValue())) {
                canuse = true;
                if ((SuccessRate == null) || (Randomizer.nextInt(100) <= SuccessRate.intValue())) {
                    success = true;
                    chr.changeSkillLevel(CurrSkillData, chr.getSkillLevel(CurrSkillData), (byte) MasterLevel.intValue());
                } else {
                    success = false;
                }
                MapleInventoryManipulator.removeFromSlot(c, GameConstants.getInventoryType(itemId), (short) slot, (short) 1, false);
                break;
            }
        }
        c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.使用技能书(chr, skill, maxlevel, canuse, success));
        c.getSession().write(MaplePacketCreator.enableActions());

        return canuse;
    }

    public static void UseSpReset(byte slot, int itemId, MapleClient c, MapleCharacter chr) {
        Item toUse = chr.getInventory(GameConstants.getInventoryType(itemId)).getItem((short) slot);
        if ((toUse != null) && (toUse.getQuantity() > 0) && (toUse.getItemId() == itemId) && (!chr.hasBlockedInventory()) && (itemId / 10000 == 250)) {
            chr.dropMessage(1, "目前不支持该道具的使用。");
            c.getSession().write(MaplePacketCreator.enableActions());
        } else {
            c.getSession().write(MaplePacketCreator.enableActions());
        }
    }

    public static void UseApReset(byte slot, int itemId, MapleClient c, MapleCharacter chr) {
        Item toUse = chr.getInventory(GameConstants.getInventoryType(itemId)).getItem((short) slot);
        if ((toUse != null) && (toUse.getQuantity() > 0) && (toUse.getItemId() == itemId) && (!chr.hasBlockedInventory()) && (itemId / 10000 == 250)) {
            chr.resetStats(4, 4, 4, 4);
            MapleInventoryManipulator.removeFromSlot(c, GameConstants.getInventoryType(itemId), (short) slot, (short) 1, false);
            c.getSession().write(MaplePacketCreator.enableActions());
        } else {
            c.getSession().write(MaplePacketCreator.enableActions());
        }
    }

    public static void UseCatchItem(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        c.getPlayer().updateTick(slea.readInt());
        c.getPlayer().setScrolledPosition((short) 0);
        byte slot = (byte) slea.readShort();
        int itemid = slea.readInt();
        MapleMonster mob = chr.getMap().getMonsterByOid(slea.readInt());
        Item toUse = chr.getInventory(MapleInventoryType.USE).getItem((short) slot);
        MapleMap map = chr.getMap();
        if ((toUse != null) && (toUse.getQuantity() > 0) && (toUse.getItemId() == itemid) && (mob != null) && (!chr.hasBlockedInventory()) && (itemid / 10000 == 227) && (MapleItemInformationProvider.getInstance().getCardMobId(itemid) == mob.getId())) {
            if ((!MapleItemInformationProvider.getInstance().isMobHP(itemid)) || (mob.getHp() <= mob.getMobMaxHp() / 2L)) {
                map.broadcastMessage(MaplePacketCreator.catchMonster(mob.getObjectId(), itemid, (byte) 1));
                map.killMonster(mob, chr, true, false, (byte) 1);
                MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false, false);
                if (MapleItemInformationProvider.getInstance().getCreateId(itemid) > 0) {
                    MapleInventoryManipulator.addById(c, MapleItemInformationProvider.getInstance().getCreateId(itemid), (short) 1, new StringBuilder().append("Catch item ").append(itemid).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                }
            } else {
                map.broadcastMessage(MaplePacketCreator.catchMonster(mob.getObjectId(), itemid, (byte) 0));
                c.getSession().write(MaplePacketCreator.catchMob(mob.getId(), itemid, (byte) 0));
            }
        }
        c.getSession().write(MaplePacketCreator.enableActions());
    }

    public static void UseMountFood(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        c.getPlayer().updateTick(slea.readInt());
        byte slot = (byte) slea.readShort();
        int itemid = slea.readInt();
        Item toUse = chr.getInventory(MapleInventoryType.USE).getItem((short) slot);
        MapleMount mount = chr.getMount();
        if ((itemid / 10000 == 226) && (toUse != null) && (toUse.getQuantity() > 0) && (toUse.getItemId() == itemid) && (mount != null) && (!c.getPlayer().hasBlockedInventory())) {
            int fatigue = mount.getFatigue();
            boolean levelup = false;
            mount.setFatigue((byte) -30);
            if (fatigue > 0) {
                mount.increaseExp();
                int level = mount.getLevel();
                if ((level < 30) && (mount.getExp() >= GameConstants.getMountExpNeededForLevel(level + 1))) {
                    mount.setLevel((byte) (level + 1));
                    levelup = true;
                }
            }
            chr.getMap().broadcastMessage(MaplePacketCreator.updateMount(chr, levelup));
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
        }
        c.getSession().write(MaplePacketCreator.enableActions());
    }

    public static void UseScriptedNPCItem(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        c.getPlayer().updateTick(slea.readInt());
        byte slot = (byte) slea.readShort();
        int itemId = slea.readInt();
        Item toUse = chr.getInventory(GameConstants.getInventoryType(itemId)).getItem((short) slot);
        long expiration_days = 0L;
        int mountid = 0;
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        ScriptedItem info = ii.getScriptedItemInfo(itemId);
        if (info == null) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        if ((toUse != null) && (toUse.getQuantity() >= 1) && (toUse.getItemId() == itemId) && (!chr.hasBlockedInventory()) && (!chr.inPVP())) {
            MapleQuestStatus marr;
            long lastTime;
            switch (toUse.getItemId()) {
                case 2430007:
                    MapleInventory inventory = chr.getInventory(MapleInventoryType.SETUP);
                    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                    if ((inventory.countById(3994102) >= 20) && (inventory.countById(3994103) >= 20) && (inventory.countById(3994104) >= 20) && (inventory.countById(3994105) >= 20)) {
                        MapleInventoryManipulator.addById(c, 2430008, (short) 1, new StringBuilder().append("Scripted item: ").append(itemId).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                        MapleInventoryManipulator.removeById(c, MapleInventoryType.SETUP, 3994102, 20, false, false);
                        MapleInventoryManipulator.removeById(c, MapleInventoryType.SETUP, 3994103, 20, false, false);
                        MapleInventoryManipulator.removeById(c, MapleInventoryType.SETUP, 3994104, 20, false, false);
                        MapleInventoryManipulator.removeById(c, MapleInventoryType.SETUP, 3994105, 20, false, false);
                    } else {
                        MapleInventoryManipulator.addById(c, 2430007, (short) 1, new StringBuilder().append("Scripted item: ").append(itemId).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                    }
                    NPCScriptManager.getInstance().start(c, 2084001);
                    break;
                case 2430008:
                    chr.saveLocation(SavedLocationType.RICHIE);

                    boolean warped = false;
                    for (int i = 390001000; i <= 390001004; i++) {
                        MapleMap map = c.getChannelServer().getMapFactory().getMap(i);
                        if (map.getCharactersSize() == 0) {
                            chr.changeMap(map, map.getPortal(0));
                            warped = true;
                            break;
                        }
                    }
                    if (warped) {
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                    } else {
                        c.getPlayer().dropMessage(5, "All maps are currently in use, please try again later.");
                    }
                    break;
                case 2430112:
                    if (c.getPlayer().getInventory(MapleInventoryType.USE).getNumFreeSlot() >= 1) {
                        if (c.getPlayer().getInventory(MapleInventoryType.USE).countById(2430112) >= 25) {
                            if ((MapleInventoryManipulator.checkSpace(c, 2049400, 1, "")) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, toUse.getItemId(), 25, true, false))) {
                                MapleInventoryManipulator.addById(c, 2049400, (short) 1, new StringBuilder().append("Scripted item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                            } else {
                                c.getPlayer().dropMessage(5, "消耗栏空间位置不足.");
                            }
                        } else if (c.getPlayer().getInventory(MapleInventoryType.USE).countById(2430112) >= 10) {
                            if ((MapleInventoryManipulator.checkSpace(c, 2049401, 1, "")) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, toUse.getItemId(), 10, true, false))) {
                                MapleInventoryManipulator.addById(c, 2049401, (short) 1, new StringBuilder().append("Scripted item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                            } else {
                                c.getPlayer().dropMessage(5, "消耗栏空间位置不足.");
                            }
                        } else {
                            NPCScriptManager.getInstance().startItem(c, info.getNpc(), toUse.getItemId());
                        }
                    } else {
                        c.getPlayer().dropMessage(5, "消耗栏空间位置不足.");
                    }
                    break;
                case 2430481:
                    if (c.getPlayer().getInventory(MapleInventoryType.USE).getNumFreeSlot() >= 1) {
                        if (c.getPlayer().getInventory(MapleInventoryType.USE).countById(2430481) >= 100) {
                            if ((MapleInventoryManipulator.checkSpace(c, 2049701, 1, "")) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, toUse.getItemId(), 100, true, false))) {
                                MapleInventoryManipulator.addById(c, 2049701, (short) 1, new StringBuilder().append("Scripted item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                            } else {
                                c.getPlayer().dropMessage(5, "消耗栏空间位置不足.");
                            }
                        } else if (c.getPlayer().getInventory(MapleInventoryType.USE).countById(2430481) >= 30) {
                            if ((MapleInventoryManipulator.checkSpace(c, 2049400, 1, "")) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, toUse.getItemId(), 30, true, false))) {
                                MapleInventoryManipulator.addById(c, 2049400, (short) 1, new StringBuilder().append("Scripted item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                            } else {
                                c.getPlayer().dropMessage(5, "消耗栏空间位置不足.");
                            }
                        } else {
                            NPCScriptManager.getInstance().startItem(c, info.getNpc(), toUse.getItemId());
                        }
                    } else {
                        c.getPlayer().dropMessage(5, "消耗栏空间位置不足.");
                    }
                    break;
                case 2430760:
                    if (c.getPlayer().getInventory(MapleInventoryType.CASH).getNumFreeSlot() >= 1) {
                        if (c.getPlayer().getInventory(MapleInventoryType.USE).countById(2430760) >= 10) {
                            if ((MapleInventoryManipulator.checkSpace(c, 5750000, 1, "")) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, toUse.getItemId(), 10, true, false))) {
                                MapleInventoryManipulator.addById(c, 5750000, (short) 1, new StringBuilder().append("Scripted item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                            } else {
                                c.getPlayer().dropMessage(5, "请检测背包空间是否足够.");
                            }
                        } else {
                            c.getPlayer().dropMessage(5, "10个星岩魔方碎片才可以兑换1个星岩魔方.");
                        }
                    } else {
                        c.getPlayer().dropMessage(5, "请检测背包空间是否足够.");
                    }
                    break;
                case 2430691:
                    if (c.getPlayer().getInventory(MapleInventoryType.CASH).getNumFreeSlot() >= 1) {
                        if (c.getPlayer().getInventory(MapleInventoryType.USE).countById(2430691) >= 10) {
                            if ((MapleInventoryManipulator.checkSpace(c, 5750001, 1, "")) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, toUse.getItemId(), 10, true, false))) {
                                MapleInventoryManipulator.addById(c, 5750001, (short) 1, new StringBuilder().append("Scripted item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                            } else {
                                c.getPlayer().dropMessage(5, "请检测背包空间是否足够.");
                            }
                        } else {
                            c.getPlayer().dropMessage(5, "10个星岩电钻机碎片才可以兑换1个星岩电钻机.");
                        }
                    } else {
                        c.getPlayer().dropMessage(5, "请检测背包空间是否足够.");
                    }
                    break;
                case 2430692:
                    if (c.getPlayer().getInventory(MapleInventoryType.SETUP).getNumFreeSlot() >= 1) {
                        if (c.getPlayer().getInventory(MapleInventoryType.USE).countById(2430692) >= 1) {
                            int rank = Randomizer.nextInt(100) < 4 ? 2 : Randomizer.nextInt(100) < 30 ? 1 : 0;
                            List pots = new LinkedList(ii.getAllSocketInfo(rank).values());
                            int newId = 0;
                            while (newId == 0) {
                                StructItemOption pot = (StructItemOption) pots.get(Randomizer.nextInt(pots.size()));
                                if (pot != null) {
                                    newId = pot.opID;
                                }
                            }
                            if ((MapleInventoryManipulator.checkSpace(c, newId, 1, "")) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, toUse.getItemId(), 1, true, false))) {
                                MapleInventoryManipulator.addById(c, newId, (short) 1, new StringBuilder().append("Scripted item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                                c.getSession().write(MaplePacketCreator.getShowItemGain(newId, (short) 1, true));
                            } else {
                                c.getPlayer().dropMessage(5, "请检测背包空间是否足够.");
                            }
                        } else {
                            c.getPlayer().dropMessage(5, "您没有星岩箱子.");
                        }
                    } else {
                        c.getPlayer().dropMessage(5, "请检测背包空间是否足够.");
                    }

                    break;
                case 5680019: {
                    int hair = 32150 + c.getPlayer().getHair() % 10;
                    c.getPlayer().setHair(hair);
                    c.getPlayer().updateSingleStat(MapleStat.发型, hair);
                    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.CASH, (short) slot, (short) 1, false);
                    break;
                }
                case 5680020: {
                    int hair = 32160 + c.getPlayer().getHair() % 10;
                    c.getPlayer().setHair(hair);
                    c.getPlayer().updateSingleStat(MapleStat.发型, hair);
                    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.CASH, (short) slot, (short) 1, false);
                    break;
                }
                case 3994225: {
                    c.getPlayer().dropMessage(5, "Please bring this item to the NPC.");
                    break;
                }
                case 2430212: {
                    marr = c.getPlayer().getQuestNAdd(MapleQuest.getInstance(122500));
                    if (marr.getCustomData() == null) {
                        marr.setCustomData("0");
                    }
                    lastTime = Long.parseLong(marr.getCustomData());
                    if (lastTime + 600000L > System.currentTimeMillis()) {
                        c.getPlayer().dropMessage(5, "疲劳恢复药 10分钟内只能使用1次，请稍后在试。");
                    } else if (c.getPlayer().getFatigue() > 0) {
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                        c.getPlayer().setFatigue(c.getPlayer().getFatigue() - 5);
                    }
                    break;
                }
                case 2430213: {
                    marr = c.getPlayer().getQuestNAdd(MapleQuest.getInstance(122500));
                    if (marr.getCustomData() == null) {
                        marr.setCustomData("0");
                    }
                    lastTime = Long.parseLong(marr.getCustomData());
                    if (lastTime + 600000L > System.currentTimeMillis()) {
                        c.getPlayer().dropMessage(5, "疲劳恢复药 10分钟内只能使用1次，请稍后在试。");
                    } else if (c.getPlayer().getFatigue() > 0) {
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                        c.getPlayer().setFatigue(c.getPlayer().getFatigue() - 10);
                    }
                    break;
                }
                case 2430214: {
                    marr = c.getPlayer().getQuestNAdd(MapleQuest.getInstance(122500));
                    if (marr.getCustomData() == null) {
                        marr.setCustomData("0");
                    }
                    lastTime = Long.parseLong(marr.getCustomData());
                    if (lastTime + 600000L > System.currentTimeMillis()) {
                        c.getPlayer().dropMessage(5, "疲劳恢复药 10分钟内只能使用1次，请稍后在试。");
                    } else if (c.getPlayer().getFatigue() > 0) {
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                        c.getPlayer().setFatigue(c.getPlayer().getFatigue() - 30);
                    }
                    break;
                }
                case 2430220: {
                    if (c.getPlayer().getFatigue() > 0) {
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                        c.getPlayer().setFatigue(c.getPlayer().getFatigue() - 30);
                    }
                    break;
                }
                case 2430227: {
                    if (c.getPlayer().getFatigue() > 0) {
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                        c.getPlayer().setFatigue(c.getPlayer().getFatigue() - 50);
                    }
                    break;
                }
                case 2430231: {
                    marr = c.getPlayer().getQuestNAdd(MapleQuest.getInstance(122500));
                    if (marr.getCustomData() == null) {
                        marr.setCustomData("0");
                    }
                    lastTime = Long.parseLong(marr.getCustomData());
                    if (lastTime + 600000L > System.currentTimeMillis()) {
                        c.getPlayer().dropMessage(5, "疲劳恢复药 10分钟内只能使用1次，请稍后在试。");
                    } else if (c.getPlayer().getFatigue() > 0) {
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                        c.getPlayer().setFatigue(c.getPlayer().getFatigue() - 40);
                    }
                    break;
                }
                case 2290285:
                case 2430144: {
                    int itemid = Randomizer.nextInt(373) + 2290000;
                    if ((MapleItemInformationProvider.getInstance().itemExists(itemid)) && (!MapleItemInformationProvider.getInstance().getName(itemid).contains("Special")) && (!MapleItemInformationProvider.getInstance().getName(itemid).contains("Event"))) {
                        MapleInventoryManipulator.addById(c, itemid, (short) 1, new StringBuilder().append("Reward item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                    }
                    break;
                }
                case 2028062:
                case 2430370: {
                    int itemid1 = Randomizer.nextInt(473) + 2510000;
                    int itemid2 = Randomizer.nextInt(158) + 2511000;
                    int itemid3 = Randomizer.nextInt(293) + 2512000;

                    int itemids = 2512291;

                    if ((c.getPlayer().getProfessionLevel(92010000) == 0) || (c.getPlayer().getProfessionLevel(92000000) == 0)) {
                        int mdsd = (int) (Math.random() * 10.0D);
                        if (mdsd <= 3) {
                            itemids = itemid3;
                        } else if (mdsd <= 6) {
                            itemids = itemid2;
                        } else if (mdsd <= 10) {
                            itemids = itemid1;
                        }
                    }

                    if ((c.getPlayer().getProfessionLevel(92010000) > 0) && (c.getPlayer().getProfessionLevel(92030000) > 0)) {
                        itemids = itemid2;
                    }

                    if ((c.getPlayer().getProfessionLevel(92010000) > 0) && (c.getPlayer().getProfessionLevel(92020000) > 0)) {
                        itemids = itemid1;
                    }

                    if ((c.getPlayer().getProfessionLevel(92000000) > 0) && (c.getPlayer().getProfessionLevel(92040000) > 0)) {
                        itemids = itemid3;
                    }

                    if ((MapleItemInformationProvider.getInstance().itemExists(itemids)) && (!MapleItemInformationProvider.getInstance().getName(itemids).contains("Special")) && (!MapleItemInformationProvider.getInstance().getName(itemids).contains("Event"))) {
                        MapleInventoryManipulator.addById(c, itemids, (short) 1, new StringBuilder().append("Reward item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                    }
                    break;
                }
                case 2430158: {
                    if (c.getPlayer().getInventory(MapleInventoryType.ETC).getNumFreeSlot() >= 1) {
                        if (c.getPlayer().getInventory(MapleInventoryType.ETC).countById(4000630) >= 100) {
                            if ((MapleInventoryManipulator.checkSpace(c, 4310010, 1, "")) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, toUse.getItemId(), 1, true, false))) {
                                MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, 4000630, 100, true, false);
                                MapleInventoryManipulator.addById(c, 4310010, (short) 1, new StringBuilder().append("Scripted item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                            } else {
                                c.getPlayer().dropMessage(5, "其他栏空间位置不足.");
                            }
                        } else if (c.getPlayer().getInventory(MapleInventoryType.ETC).countById(4000630) >= 50) {
                            if ((MapleInventoryManipulator.checkSpace(c, 4310009, 1, "")) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, toUse.getItemId(), 1, true, false))) {
                                MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, 4000630, 50, true, false);
                                MapleInventoryManipulator.addById(c, 4310009, (short) 1, new StringBuilder().append("Scripted item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                            } else {
                                c.getPlayer().dropMessage(5, "其他栏空间位置不足.");
                            }
                        } else {
                            c.getPlayer().dropMessage(5, "需要50个净化图腾才能兑换出狮子王的贵族勋章，100个净化图腾才能兑换狮子王的皇家勋章。");
                        }
                    } else {
                        c.getPlayer().dropMessage(5, "其他栏空间位置不足.");
                    }
                    break;
                }
                case 2430159: {
                    MapleQuest.getInstance(3182).forceComplete(c.getPlayer(), 2161004);
                    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                    break;
                }
                case 2430200: {
                    if (c.getPlayer().getQuestStatus(31152) != 2) {
                        c.getPlayer().dropMessage(5, "你没有接受任务.");
                    } else if (c.getPlayer().getInventory(MapleInventoryType.ETC).getNumFreeSlot() >= 1) {
                        if ((c.getPlayer().getInventory(MapleInventoryType.ETC).countById(4000660) >= 1) && (c.getPlayer().getInventory(MapleInventoryType.ETC).countById(4000661) >= 1) && (c.getPlayer().getInventory(MapleInventoryType.ETC).countById(4000662) >= 1) && (c.getPlayer().getInventory(MapleInventoryType.ETC).countById(4000663) >= 1)) {
                            if ((MapleInventoryManipulator.checkSpace(c, 4032923, 1, "")) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, toUse.getItemId(), 1, true, false)) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, 4000660, 1, true, false)) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, 4000661, 1, true, false)) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, 4000662, 1, true, false)) && (MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, 4000663, 1, true, false))) {
                                MapleInventoryManipulator.addById(c, 4032923, (short) 1, new StringBuilder().append("Scripted item: ").append(toUse.getItemId()).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                            } else {
                                c.getPlayer().dropMessage(5, "其他栏空间位置不足.");
                            }
                        } else {
                            c.getPlayer().dropMessage(5, "There needs to be 1 of each Stone for a Dream Key.");
                        }
                    } else {
                        c.getPlayer().dropMessage(5, "其他栏空间位置不足.");
                    }

                    break;
                }
                case 2430130: {
                    if (GameConstants.is反抗者(c.getPlayer().getJob())) {
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                        c.getPlayer().gainExp(20000 + c.getPlayer().getLevel() * 50 * c.getChannelServer().getExpRate(), true, true, false);
                    } else {
                        c.getPlayer().dropMessage(5, "您无法使用这个道具。");
                    }
                    break;
                }
                case 2430131: {
                    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                    c.getPlayer().gainExp(20000 + c.getPlayer().getLevel() * 50 * c.getChannelServer().getExpRate(), true, true, false);
                    break;
                }
                case 2430132:
                case 2430133:
                case 2430134:
                case 2430142: {
                    if (c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNumFreeSlot() >= 1) {
                        if ((c.getPlayer().getJob() == 3200) || (c.getPlayer().getJob() == 3210) || (c.getPlayer().getJob() == 3211) || (c.getPlayer().getJob() == 3212)) {
                            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                            MapleInventoryManipulator.addById(c, 1382101, (short) 1, new StringBuilder().append("Scripted item: ").append(itemId).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                        } else if ((c.getPlayer().getJob() == 3300) || (c.getPlayer().getJob() == 3310) || (c.getPlayer().getJob() == 3311) || (c.getPlayer().getJob() == 3312)) {
                            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                            MapleInventoryManipulator.addById(c, 1462093, (short) 1, new StringBuilder().append("Scripted item: ").append(itemId).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                        } else if ((c.getPlayer().getJob() == 3500) || (c.getPlayer().getJob() == 3510) || (c.getPlayer().getJob() == 3511) || (c.getPlayer().getJob() == 3512)) {
                            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                            MapleInventoryManipulator.addById(c, 1492080, (short) 1, new StringBuilder().append("Scripted item: ").append(itemId).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
                        } else {
                            c.getPlayer().dropMessage(5, "您无法使用这个道具。");
                        }
                    } else {
                        c.getPlayer().dropMessage(5, "背包空间不足。");
                    }
                }
                break;
                case 2430455:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430455);
                    break;
                case 2430467:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430467);
                    break;
                case 2430638:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430638);
                    break;
                case 2430639:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430639);
                    break;
                case 2430640:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430640);
                    break;
                case 2430376:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430376);
                    break;
                case 2430377:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430377);
                    break;
                case 2430378:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430378);
                    break;
                case 2430379:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430379);
                    break;
                case 2430380:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430380);
                    break;
                case 2430382:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430382);
                    break;
                case 2430385:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430385);
                    break;
                case 2430386:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430386);
                    break;
                case 2430387:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430387);
                    break;
                case 2430388:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430388);
                    break;
                case 2430389:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430389);
                    break;
                case 2430390:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430390);
                    break;
                case 2430391:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430391);
                    break;
                case 2430394:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430394);
                    break;
                case 2430398:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430398);
                    break;
                case 2430399:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430399);
                    break;
                case 2430443:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430443);
                    break;
                case 2430444:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430444);
                    break;
                case 2430445:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430445);
                    break;
                case 2430446:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430446);
                    break;
                case 2430447:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430447);
                    break;
                case 2430448:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430448);
                    break;
                case 2430449:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430449);
                    break;
                case 2430450:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430450);
                    break;
                case 2430451:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430451);
                    break;
                case 2430452:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430452);
                    break;
                case 2430453:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430453);
                    break;
                case 2430456:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430456);
                    break;
                case 2430457:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430457);
                    break;
                case 2430460:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430460);
                    break;
                case 2430469:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430469);
                    break;
                case 2430470:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430470);
                    break;
                case 2430471:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430471);
                    break;
                case 2430472:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430472);
                    break;
                case 2430473:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430473);
                    break;
                case 2430474:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430474);
                    break;
                case 2430479:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430479);
                    break;
                case 2430482:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430482);
                    break;
                case 2430484:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430484);
                    break;
                case 2430489:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430489);
                    break;
                case 2430252:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430252);
                    break;
                case 2430514:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430514);
                    break;
                case 2430499:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430499);
                    break;
                case 2430498:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430498);
                    break;
                case 2430495:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430495);
                    break;
                case 2430483:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430483);
                    break;
                case 2430515:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430515);
                    break;
                case 2430516:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430516);
                    break;
                case 2430517:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430517);
                    break;
                case 2430518:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430518);
                    break;
                case 2430520:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430520);
                    break;
                case 2430526:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430526);
                    break;
                case 2430528:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430528);
                    break;
                case 2430529:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430529);
                    break;
                case 2430540:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430540);
                    break;
                case 2430548:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430548);
                    break;
                case 2430558:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430558);
                    break;
                case 2430559:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430559);
                    break;
                case 2430564:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430564);
                    break;
                case 2430565:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430565);
                    break;
                case 2430606:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430606);
                    break;
                case 2430607:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430607);
                    break;
                case 2430608:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430608);
                    break;
                case 2430611:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430611);
                    break;
                case 2430612:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430612);
                    break;
                case 2430622:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430622);
                    break;
                case 2430623:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430623);
                    break;
                case 2430625:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430625);
                    break;
                case 2430626:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430626);
                    break;
                case 2430627:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430627);
                    break;
                case 2430631:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430631);
                    break;
                case 2430632:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430632);
                    break;
                case 2430635:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430635);
                    break;
                case 2430636:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430636);
                    break;
                case 2430641:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430641);
                    break;
                case 2430647:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430647);
                    break;
                case 2430648:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430648);
                    break;
                case 2430649:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430649);
                    break;
                case 2430658:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430658);
                    break;
                case 2430661:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430661);
                    break;
                case 2430665:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430665);
                    break;
                case 2430668:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430668);
                    break;
                case 2430669:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430669);
                    break;
                case 2430672:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430672);
                    break;
                case 2430673:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430673);
                    break;
                case 2430656:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430656);
                    break;
                case 2430761:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430761);
                    break;
                case 2430674:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430674);
                    break;
                case 2430675:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430675);
                    break;
                case 2430682:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430682);
                    break;
                case 2430683:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430683);
                    break;
                case 2430685:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430685);
                    break;
                case 2430686:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430686);
                    break;
                case 2430690:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430690);
                    break;
                case 2430693:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430693);
                    break;
                case 2430694:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430694);
                    break;
                case 2430695:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430695);
                    break;
                case 2430989:
                    NPCScriptManager.getInstance().startItem(c, 9010000, 2430989);
                    break;
                case 2430169:
                    mountid = 1027;
                    expiration_days = 1L;
                    break;
                case 2430170:
                    mountid = 1027;
                    expiration_days = 7L;
                    break;
                case 2430037:
                    mountid = 1028;
                    expiration_days = 1L;
                    break;
                case 2430038:
                    mountid = 1029;
                    expiration_days = 1L;
                    break;
                case 2430039:
                    mountid = 1030;
                    expiration_days = 1L;
                    break;
                case 2430040:
                    mountid = 1031;
                    expiration_days = 1L;
                    break;
                case 2430223:
                    mountid = 1031;
                    expiration_days = 15L;
                    break;
                case 2430259:
                    mountid = 1031;
                    expiration_days = 3L;
                    break;
                case 2430242:
                    mountid = 80001018;
                    expiration_days = 10L;
                    break;
                case 2430243:
                    mountid = 80001019;
                    expiration_days = 10L;
                    break;
                case 2430261:
                    mountid = 80001019;
                    expiration_days = 3L;
                    break;
                case 2430249:
                    mountid = 80001027;
                    expiration_days = 3L;
                    break;
                case 2430225:
                    mountid = 1031;
                    expiration_days = 10L;
                    break;
                case 2430053:
                    mountid = 1027;
                    expiration_days = 1L;
                    break;
                case 2430054:
                    mountid = 1028;
                    expiration_days = 30L;
                    break;
                case 2430055:
                    mountid = 1029;
                    expiration_days = 30L;
                    break;
                case 2430257:
                    mountid = 1029;
                    expiration_days = 7L;
                    break;
                case 2430056:
                    mountid = 1035;
                    expiration_days = 30L;
                    break;
                case 2430057:
                    mountid = 1033;
                    expiration_days = 30L;
                    break;
                case 2430072:
                    mountid = 1034;
                    expiration_days = 7L;
                    break;
                case 2430073:
                    mountid = 1036;
                    expiration_days = 15L;
                    break;
                case 2430074:
                    mountid = 1037;
                    expiration_days = 15L;
                    break;
                case 2430272:
                    mountid = 1038;
                    expiration_days = 3L;
                    break;
                case 2430275:
                    mountid = 80001033;
                    expiration_days = 7L;
                    break;
                case 2430075:
                    mountid = 1038;
                    expiration_days = 15L;
                    break;
                case 2430076:
                    mountid = 1039;
                    expiration_days = 15L;
                    break;
                case 2430077:
                    mountid = 1040;
                    expiration_days = 15L;
                    break;
                case 2430080:
                    mountid = 1042;
                    expiration_days = 20L;
                    break;
                case 2430082:
                    mountid = 1044;
                    expiration_days = 7L;
                    break;
                case 2430260:
                    mountid = 1044;
                    expiration_days = 3L;
                    break;
                case 2430091:
                    mountid = 1049;
                    expiration_days = 10L;
                    break;
                case 2430092:
                    mountid = 1050;
                    expiration_days = 10L;
                    break;
                case 2430263:
                    mountid = 1050;
                    expiration_days = 3L;
                    break;
                case 2430093:
                    mountid = 1051;
                    expiration_days = 10L;
                    break;
                case 2430101:
                    mountid = 1052;
                    expiration_days = 10L;
                    break;
                case 2430102:
                    mountid = 1053;
                    expiration_days = 10L;
                    break;
                case 2430103:
                    mountid = 1054;
                    expiration_days = 30L;
                    break;
                case 2430266:
                    mountid = 1054;
                    expiration_days = 3L;
                    break;
                case 2430265:
                    mountid = 1151;
                    expiration_days = 3L;
                    break;
                case 2430258:
                    mountid = 1115;
                    expiration_days = 365L;
                    break;
                case 2430117:
                    mountid = 1036;
                    expiration_days = 365L;
                    break;
                case 2430118:
                    mountid = 1039;
                    expiration_days = 365L;
                    break;
                case 2430119:
                    mountid = 1040;
                    expiration_days = 365L;
                    break;
                case 2430120:
                    mountid = 1037;
                    expiration_days = 365L;
                    break;
                case 2430271:
                    mountid = 1069;
                    expiration_days = 3L;
                    break;
                case 2430136:
                    mountid = 1069;
                    expiration_days = 15L;
                    break;
                case 2430137:
                    mountid = 1069;
                    expiration_days = 30L;
                    break;
                case 2430138:
                    mountid = 1069;
                    expiration_days = 365L;
                    break;
                case 2430145:
                    mountid = 1070;
                    expiration_days = 30L;
                    break;
                case 2430146:
                    mountid = 1070;
                    expiration_days = 365L;
                    break;
                case 2430147:
                    mountid = 1071;
                    expiration_days = 30L;
                    break;
                case 2430148:
                    mountid = 1071;
                    expiration_days = 365L;
                    break;
                case 2430135:
                    mountid = 1065;
                    expiration_days = 15L;
                    break;
                case 2430149:
                    mountid = 1072;
                    expiration_days = 30L;
                    break;
                case 2430262:
                    mountid = 1072;
                    expiration_days = 3L;
                    break;
                case 2430179:
                    mountid = 1081;
                    expiration_days = 15L;
                    break;
                case 2430264:
                    mountid = 1081;
                    expiration_days = 3L;
                    break;
                case 2430201:
                    mountid = 1096;
                    expiration_days = 3L;
                    break;
                case 2430228:
                    mountid = 1101;
                    expiration_days = 15L;
                    break;
                case 2430276:
                    mountid = 1101;
                    expiration_days = 15L;
                    break;
                case 2430277:
                    mountid = 1101;
                    expiration_days = 365L;
                    break;
                case 2430283:
                    mountid = 1025;
                    expiration_days = 10L;
                    break;
                case 2430291:
                    mountid = 1145;
                    expiration_days = -1L;
                    break;
                case 2430293:
                    mountid = 1146;
                    expiration_days = -1L;
                    break;
                case 2430295:
                    mountid = 1147;
                    expiration_days = -1L;
                    break;
                case 2430297:
                    mountid = 1148;
                    expiration_days = -1L;
                    break;
                case 2430299:
                    mountid = 1149;
                    expiration_days = -1L;
                    break;
                case 2430301:
                    mountid = 1150;
                    expiration_days = -1L;
                    break;
                case 2430303:
                    mountid = 1151;
                    expiration_days = -1L;
                    break;
                case 2430305:
                    mountid = 1152;
                    expiration_days = -1L;
                    break;
                case 2430307:
                    mountid = 1153;
                    expiration_days = -1L;
                    break;
                case 2430309:
                    mountid = 1154;
                    expiration_days = -1L;
                    break;
                case 2430311:
                    mountid = 1156;
                    expiration_days = -1L;
                    break;
                case 2430313:
                    mountid = 1156;
                    expiration_days = -1L;
                    break;
                case 2430315:
                    mountid = 1118;
                    expiration_days = -1L;
                    break;
                case 2430317:
                    mountid = 1121;
                    expiration_days = -1L;
                    break;
                case 2430319:
                    mountid = 1122;
                    expiration_days = -1L;
                    break;
                case 2430321:
                    mountid = 1123;
                    expiration_days = -1L;
                    break;
                case 2430323:
                    mountid = 1124;
                    expiration_days = -1L;
                    break;
                case 2430325:
                    mountid = 1129;
                    expiration_days = -1L;
                    break;
                case 2430327:
                    mountid = 1130;
                    expiration_days = -1L;
                    break;
                case 2430329:
                    mountid = 1063;
                    expiration_days = -1L;
                    break;
                case 2430331:
                    mountid = 1025;
                    expiration_days = -1L;
                    break;
                case 2430333:
                    mountid = 1034;
                    expiration_days = -1L;
                    break;
                case 2430335:
                    mountid = 1136;
                    expiration_days = -1L;
                    break;
                case 2430337:
                    mountid = 1051;
                    expiration_days = -1L;
                    break;
                case 2430339:
                    mountid = 1138;
                    expiration_days = -1L;
                    break;
                case 2430341:
                    mountid = 1139;
                    expiration_days = -1L;
                    break;
                case 2430343:
                    mountid = 1027;
                    expiration_days = -1L;
                    break;
                case 2430346:
                    mountid = 1029;
                    expiration_days = -1L;
                    break;
                case 2430348:
                    mountid = 1028;
                    expiration_days = -1L;
                    break;
                case 2430350:
                    mountid = 1033;
                    expiration_days = -1L;
                    break;
                case 2430352:
                    mountid = 1064;
                    expiration_days = -1L;
                    break;
                case 2430354:
                    mountid = 1096;
                    expiration_days = -1L;
                    break;
                case 2430356:
                    mountid = 1101;
                    expiration_days = -1L;
                    break;
                case 2430358:
                    mountid = 1102;
                    expiration_days = -1L;
                    break;
                case 2430360:
                    mountid = 1054;
                    expiration_days = -1L;
                    break;
                case 2430362:
                    mountid = 1053;
                    expiration_days = -1L;
                    break;
                case 2430292:
                    mountid = 1145;
                    expiration_days = 90L;
                    break;
                case 2430294:
                    mountid = 1146;
                    expiration_days = 90L;
                    break;
                case 2430296:
                    mountid = 1147;
                    expiration_days = 90L;
                    break;
                case 2430298:
                    mountid = 1148;
                    expiration_days = 90L;
                    break;
                case 2430300:
                    mountid = 1149;
                    expiration_days = 90L;
                    break;
                case 2430302:
                    mountid = 1150;
                    expiration_days = 90L;
                    break;
                case 2430304:
                    mountid = 1151;
                    expiration_days = 90L;
                    break;
                case 2430306:
                    mountid = 1152;
                    expiration_days = 90L;
                    break;
                case 2430308:
                    mountid = 1153;
                    expiration_days = 90L;
                    break;
                case 2430310:
                    mountid = 1154;
                    expiration_days = 90L;
                    break;
                case 2430312:
                    mountid = 1156;
                    expiration_days = 90L;
                    break;
                case 2430314:
                    mountid = 1156;
                    expiration_days = 90L;
                    break;
                case 2430316:
                    mountid = 1118;
                    expiration_days = 90L;
                    break;
                case 2430318:
                    mountid = 1121;
                    expiration_days = 90L;
                    break;
                case 2430320:
                    mountid = 1122;
                    expiration_days = 90L;
                    break;
                case 2430322:
                    mountid = 1123;
                    expiration_days = 90L;
                    break;
                case 2430326:
                    mountid = 1129;
                    expiration_days = 90L;
                    break;
                case 2430328:
                    mountid = 1130;
                    expiration_days = 90L;
                    break;
                case 2430330:
                    mountid = 1063;
                    expiration_days = 90L;
                    break;
                case 2430332:
                    mountid = 1025;
                    expiration_days = 90L;
                    break;
                case 2430334:
                    mountid = 1034;
                    expiration_days = 90L;
                    break;
                case 2430336:
                    mountid = 1136;
                    expiration_days = 90L;
                    break;
                case 2430338:
                    mountid = 1051;
                    expiration_days = 90L;
                    break;
                case 2430340:
                    mountid = 1138;
                    expiration_days = 90L;
                    break;
                case 2430342:
                    mountid = 1139;
                    expiration_days = 90L;
                    break;
                case 2430344:
                    mountid = 1027;
                    expiration_days = 90L;
                    break;
                case 2430347:
                    mountid = 1029;
                    expiration_days = 90L;
                    break;
                case 2430349:
                    mountid = 1028;
                    expiration_days = 90L;
                    break;
                case 2430351:
                    mountid = 1033;
                    expiration_days = 90L;
                    break;
                case 2430353:
                    mountid = 1064;
                    expiration_days = 90L;
                    break;
                case 2430355:
                    mountid = 1096;
                    expiration_days = 90L;
                    break;
                case 2430357:
                    mountid = 1101;
                    expiration_days = 90L;
                    break;
                case 2430359:
                    mountid = 1102;
                    expiration_days = 90L;
                    break;
                case 2430361:
                    mountid = 1054;
                    expiration_days = 90L;
                    break;
                case 2430363:
                    mountid = 1053;
                    expiration_days = 90L;
                    break;
                case 2430324:
                    mountid = 1158;
                    expiration_days = -1L;
                    break;
                case 2430345:
                    mountid = 1158;
                    expiration_days = 90L;
                    break;
                case 2430367:
                    mountid = 1115;
                    expiration_days = 3L;
                    break;
                case 2430365:
                    mountid = 1025;
                    expiration_days = 365L;
                    break;
                case 2430366:
                    mountid = 1025;
                    expiration_days = 15L;
                    break;
                case 2430369:
                    mountid = 1049;
                    expiration_days = 10L;
                    break;
                case 2430392:
                    mountid = 80001038;
                    expiration_days = 90L;
                    break;
                case 2430476:
                    mountid = 1039;
                    expiration_days = 15L;
                    break;
                case 2430477:
                    mountid = 1039;
                    expiration_days = 365L;
                    break;
                case 2430232:
                    mountid = 1106;
                    expiration_days = 10L;
                    break;
                case 2430511:
                    mountid = 80001033;
                    expiration_days = 15L;
                    break;
                case 2430512:
                    mountid = 80001033;
                    expiration_days = 365L;
                    break;
                case 2430536:
                    mountid = 80001114;
                    expiration_days = -1L;
                    break;
                case 2430537:
                    mountid = 80001114;
                    expiration_days = 90L;
                    break;
                case 2430229:
                    mountid = 1102;
                    expiration_days = 60L;
                    break;
                case 2430199:
                    mountid = 1102;
                    expiration_days = 1L;
                    break;
                case 2430206:
                    mountid = 1089;
                    expiration_days = 7L;
                    break;
                case 2430211:
                    mountid = 80001009;
                    expiration_days = 30L;
                    break;
                default:
                    NPCScriptManager.getInstance().startItem(c, info.getNpc(), toUse.getItemId());
            }
        }

        if (mountid > 0) {
            mountid = PlayerStats.getSkillByJob(mountid, c.getPlayer().getJob());
            int fk = GameConstants.getMountItem(mountid, c.getPlayer());
            if ((GameConstants.GMS) && (fk > 0) && (mountid < 80001000)) {
                for (int i = 80001001; i < 80001999; i++) {
                    Skill skill = SkillFactory.getSkill(i);
                    if ((skill != null) && (GameConstants.getMountItem(skill.getId(), c.getPlayer()) == fk)) {
                        mountid = i;
                        break;
                    }
                }
            }
            if (c.getPlayer().getSkillLevel(mountid) > 0) {
                c.getPlayer().dropMessage(5, "您已经拥有了这个骑宠的技能.");
            } else if ((SkillFactory.getSkill(mountid) == null) || (GameConstants.getMountItem(mountid, c.getPlayer()) == 0)) {
                c.getPlayer().dropMessage(5, "您无法使用这个骑宠的技能.");
            } else if (expiration_days > 0L) {
                MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
                c.getPlayer().changeSkillLevel(SkillFactory.getSkill(mountid), 1, (byte) 1, System.currentTimeMillis() + expiration_days * 24L * 60L * 60L * 1000L);
                c.getPlayer().dropMessage(5, "恭喜您获得骑宠技能.");
            }
        }
        c.getSession().write(MaplePacketCreator.enableActions());
    }

    public static void UseSummonBag(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        if ((!chr.isAlive()) || (chr.hasBlockedInventory()) || (chr.inPVP())) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        c.getPlayer().updateTick(slea.readInt());
        byte slot = (byte) slea.readShort();
        int itemId = slea.readInt();
        Item toUse = chr.getInventory(MapleInventoryType.USE).getItem((short) slot);
        if ((toUse != null) && (toUse.getQuantity() >= 1) && (toUse.getItemId() == itemId) && ((c.getPlayer().getMapId() < 910000000) || (c.getPlayer().getMapId() > 910000022))) {
            Map<String, Integer> toSpawn = MapleItemInformationProvider.getInstance().getEquipStats(itemId);
            if (toSpawn == null) {
                c.getSession().write(MaplePacketCreator.enableActions());
                return;
            }
            MapleMonster ht = null;
            int type = 0;
            for (Entry<String, Integer> i : toSpawn.entrySet()) {
                if ((((String) i.getKey()).startsWith("mob")) && (Randomizer.nextInt(99) <= ((Integer) i.getValue()).intValue())) {
                    ht = MapleLifeFactory.getMonster(Integer.parseInt(((String) i.getKey()).substring(3)));
                    chr.getMap().spawnMonster_sSack(ht, chr.getPosition(), type);
                }
            }
            if (ht == null) {
                c.getSession().write(MaplePacketCreator.enableActions());
                return;
            }
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
        }
        c.getSession().write(MaplePacketCreator.enableActions());
    }

    public static void UseTreasureChest(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        short slot = slea.readShort();
        int itemid = slea.readInt();
        boolean useCash = slea.readByte() > 0;
        Item toUse = chr.getInventory(MapleInventoryType.ETC).getItem((short) (byte) slot);
        if ((toUse == null) || (toUse.getQuantity() <= 0) || (toUse.getItemId() != itemid) || (chr.hasBlockedInventory())) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        if ((!chr.getCheatTracker().canMZD()) && (!chr.isGM())) {
            chr.dropMessage(5, "你需要等待5秒之后才能使用谜之蛋.");
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }

        int keyIDforRemoval = 0;

        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        int reward;
        String box;
        String key;
        int price;
        switch (toUse.getItemId()) {
            case 4280000:
                reward = RandomRewards.getGoldBoxReward();
                keyIDforRemoval = 5490000;
                box = "永恒的谜之蛋";
                key = "永恒的热度";
                price = 800;
                break;
            case 4280001:
                reward = RandomRewards.getSilverBoxReward();
                keyIDforRemoval = 5490001;
                box = "重生的谜之蛋";
                key = "重生的热度";
                price = 500;
                break;
            case 4280005:
                reward = RandomRewards.getSilverBoxReward();
                keyIDforRemoval = 5490005;
                box = "银色宝物盒";
                key = "可爱银钥匙";
                price = 500;
                break;
            case 4280006:
                reward = RandomRewards.getSilverBoxReward();
                keyIDforRemoval = 5490006;
                box = "金色宝物盒";
                key = "可爱银钥匙";
                price = 800;
                break;
            case 4280002:
            case 4280003:
            case 4280004:
            default:
                return;
        }
        int amount = 1;
        switch (reward) {
            case 2000004:
                amount = 200;
                break;
            case 2000005:
                amount = 100;
        }

        int 概率 = Randomizer.nextInt(1000);
        if (概率 >= 999) {
            reward = RandomRewards.get水晶天平();
        } else if (概率 >= 998) {
            reward = RandomRewards.get所有椅子();
        }

        if ((useCash) && (chr.getCSPoints(2) < price)) {
            chr.dropMessage(1, new StringBuilder().append("抵用券不足").append(price).append("点，请到商城购买“抵用券兑换包”即可充值抵用券！").toString());
            c.getSession().write(MaplePacketCreator.enableActions());
        } else if (chr.getInventory(MapleInventoryType.CASH).countById(keyIDforRemoval) < 0) {
            chr.dropMessage(1, new StringBuilder().append("孵化").append(box).append("需要").append(key).append("，请到商城购买！").toString());
            c.getSession().write(MaplePacketCreator.enableActions());
        } else if ((chr.getInventory(MapleInventoryType.CASH).countById(keyIDforRemoval) > 0) || ((useCash) && (chr.getCSPoints(2) > price))) {
            Item item = MapleInventoryManipulator.addbyId_Gachapon(c, reward, (short) amount);
            if (item == null) {
                chr.dropMessage(1, "孵化失败，请重试一次。");
                c.getSession().write(MaplePacketCreator.enableActions());
                return;
            }
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.ETC, (short) (byte) slot, (short) 1, true);
            if (useCash) {
                chr.modifyCSPoints(2, -price, true);
            } else {
                MapleInventoryManipulator.removeById(c, MapleInventoryType.CASH, keyIDforRemoval, 1, true, false);
            }
            c.getSession().write(MaplePacketCreator.getShowItemGain(reward, (short) amount, true));
            byte rareness = GameConstants.gachaponRareItem(item.getItemId());
            if (rareness > 0) {
                Broadcast.broadcastMessage(MaplePacketCreator.转蛋机喇叭(c.getPlayer().getName(), new StringBuilder().append(" : 从").append(box).append("中获得{").append(ii.getName(item.getItemId())).append("}！大家一起恭喜他（她）吧！！！！").toString(), item, rareness, c.getChannel()));
            }
        } else {
            chr.dropMessage(5, new StringBuilder().append("孵化").append(box).append("失败，进检查是否有").append(key).append("或者抵用卷大于").append(price).append("点。").toString());
            c.getSession().write(MaplePacketCreator.enableActions());
        }
    }

    public static void Pickup_Player(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        if (c.getPlayer().hasBlockedInventory()) {
            return;
        }
        chr.updateTick(slea.readInt());
        c.getPlayer().setScrolledPosition((short) 0);
        slea.skip(1);
        Point Client_Reportedpos = slea.readPos();
        if ((chr == null) || (chr.getMap() == null)) {
            return;
        }
        MapleMapObject ob = chr.getMap().getMapObject(slea.readInt(), MapleMapObjectType.ITEM);
        if (ob == null) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        MapleMapItem mapitem = (MapleMapItem) ob;
        Lock lock = mapitem.getLock();
        lock.lock();
        try {
            if (mapitem.isPickedUp()) {
                c.getSession().write(MaplePacketCreator.enableActions());
            } else if ((mapitem.getQuest() > 0) && (chr.getQuestStatus(mapitem.getQuest()) != 1)) {
                c.getSession().write(MaplePacketCreator.enableActions());
            } else if ((mapitem.getOwner() != chr.getId()) && (((!mapitem.isPlayerDrop()) && (mapitem.getDropType() == 0)) || ((mapitem.isPlayerDrop()) && (chr.getMap().getEverlast())))) {
                c.getSession().write(MaplePacketCreator.enableActions());
            } else if ((!mapitem.isPlayerDrop()) && (mapitem.getDropType() == 1) && (mapitem.getOwner() != chr.getId()) && ((chr.getParty() == null) || (chr.getParty().getMemberById(mapitem.getOwner()) == null))) {
                c.getSession().write(MaplePacketCreator.enableActions());
            } else {
                double Distance = Client_Reportedpos.distanceSq(mapitem.getPosition());
                if ((Distance > 5000.0D) && ((mapitem.getMeso() > 0) || (mapitem.getItemId() != 4001025))) {
                    chr.getCheatTracker().registerOffense(CheatingOffense.ITEMVAC_CLIENT, String.valueOf(Distance));
                    Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, new StringBuilder().append("[GM Message] ").append(chr.getName()).append(" (等级 ").append(chr.getLevel()).append(") 全屏捡物。地图ID: ").append(chr.getMapId()).toString()));
                } else if (chr.getPosition().distanceSq(mapitem.getPosition()) > 640000.0D) {
                    chr.getCheatTracker().registerOffense(CheatingOffense.ITEMVAC_SERVER);
                    Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, new StringBuilder().append("[GM Message] ").append(chr.getName()).append(" (等级 ").append(chr.getLevel()).append(") 全屏捡物。地图ID: ").append(chr.getMapId()).toString()));
                }
                if (mapitem.getMeso() > 0) {
                    if ((chr.getParty() != null) && (mapitem.getOwner() != chr.getId())) {
                        List<MapleCharacter> toGive = new LinkedList<MapleCharacter>();
                        int splitMeso = mapitem.getMeso() * 40 / 100;
                        for (MaplePartyCharacter z : chr.getParty().getMembers()) {
                            MapleCharacter m = chr.getMap().getCharacterById(z.getId());
                            if ((m != null) && (m.getId() != chr.getId())) {
                                toGive.add(m);
                            }
                        }
                        for (MapleCharacter m : toGive) {
                            m.gainMeso(splitMeso / toGive.size() + (m.getStat().hasPartyBonus ? (int) (mapitem.getMeso() / 20.0D) : 0), true);
                        }
                        chr.gainMeso(mapitem.getMeso() - splitMeso, true);
                    } else {
                        chr.gainMeso(mapitem.getMeso(), true);
                    }
                    removeItem(chr, mapitem, ob);
                } else if (MapleItemInformationProvider.getInstance().isPickupBlocked(mapitem.getItemId())) {
                    c.getSession().write(MaplePacketCreator.enableActions());
                    c.getPlayer().dropMessage(5, "这个道具无法捡取.");
                } else if ((c.getPlayer().inPVP()) && (Integer.parseInt(c.getPlayer().getEventInstance().getProperty("ice")) == c.getPlayer().getId())) {
                    c.getSession().write(MaplePacketCreator.getInventoryFull());
                    c.getSession().write(MaplePacketCreator.getShowInventoryFull());
                    c.getSession().write(MaplePacketCreator.enableActions());
                } else if (useItem(c, mapitem.getItemId())) {
                    removeItem(c.getPlayer(), mapitem, ob);

                    if (mapitem.getItemId() / 10000 == 291) {
                        c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getCapturePosition(c.getPlayer().getMap()));
                        c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.resetCapture());
                    }
                } else if ((mapitem.getItemId() / 10000 != 291) && (MapleInventoryManipulator.checkSpace(c, mapitem.getItemId(), mapitem.getItem().getQuantity(), mapitem.getItem().getOwner()))) {
                    if ((mapitem.getItem().getQuantity() >= 50) && (mapitem.getItemId() == 2340000)) {
                        c.setMonitored(true);
                    }
                    MapleInventoryManipulator.addFromDrop(c, mapitem.getItem(), true, mapitem.getDropper() instanceof MapleMonster);
                    removeItem(chr, mapitem, ob);
                } else {
                    c.getSession().write(MaplePacketCreator.getInventoryFull());
                    c.getSession().write(MaplePacketCreator.getShowInventoryFull());
                    c.getSession().write(MaplePacketCreator.enableActions());
                }
            }
        } finally {
            lock.unlock();
        }
    }

    public static void Pickup_Pet(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        if (chr == null) {
            return;
        }
        if ((c.getPlayer().hasBlockedInventory()) || (c.getPlayer().inPVP())) {
            return;
        }
        c.getPlayer().setScrolledPosition((short) 0);
        byte petz = (byte) slea.readInt();
        MaplePet pet = chr.getPet(petz);
        slea.skip(1);
        chr.updateTick(slea.readInt());
        Point Client_Reportedpos = slea.readPos();
        MapleMapObject ob = chr.getMap().getMapObject(slea.readInt(), MapleMapObjectType.ITEM);
        if ((ob == null) || (pet == null)) {
            return;
        }
        MapleMapItem mapitem = (MapleMapItem) ob;
        Lock lock = mapitem.getLock();
        lock.lock();
        try {
            if (mapitem.isPickedUp()) {
                c.getSession().write(MaplePacketCreator.getInventoryFull());
            } else {
                if ((mapitem.getOwner() != chr.getId()) && (mapitem.isPlayerDrop())) {
                    return;
                }
                if ((mapitem.getOwner() != chr.getId()) && (((!mapitem.isPlayerDrop()) && (mapitem.getDropType() == 0)) || ((mapitem.isPlayerDrop()) && (chr.getMap().getEverlast())))) {
                    c.getSession().write(MaplePacketCreator.enableActions());
                } else if ((!mapitem.isPlayerDrop()) && (mapitem.getDropType() == 1) && (mapitem.getOwner() != chr.getId()) && ((chr.getParty() == null) || (chr.getParty().getMemberById(mapitem.getOwner()) == null))) {
                    c.getSession().write(MaplePacketCreator.enableActions());
                } else {
                    double Distance = Client_Reportedpos.distanceSq(mapitem.getPosition());
                    if ((Distance > 10000.0D) && ((mapitem.getMeso() > 0) || (mapitem.getItemId() != 4001025))) {
                        chr.getCheatTracker().registerOffense(CheatingOffense.PET_ITEMVAC_CLIENT, String.valueOf(Distance));
                        Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, new StringBuilder().append("[GM Message] ").append(chr.getName()).append(" (等级 ").append(chr.getLevel()).append(") 全屏宠吸。地图ID: ").append(chr.getMapId()).toString()));
                    } else if (pet.getPos().distanceSq(mapitem.getPosition()) > 640000.0D) {
                        chr.getCheatTracker().registerOffense(CheatingOffense.PET_ITEMVAC_SERVER);
                        Broadcast.broadcastGMMessage(MaplePacketCreator.serverNotice(6, new StringBuilder().append("[GM Message] ").append(chr.getName()).append(" (等级 ").append(chr.getLevel()).append(") 全屏宠吸。地图ID: ").append(chr.getMapId()).toString()));
                    }
                    if (mapitem.getMeso() > 0) {
                        if ((chr.getParty() != null) && (mapitem.getOwner() != chr.getId())) {
                            List<MapleCharacter> toGive = new LinkedList<MapleCharacter>();
                            int splitMeso = mapitem.getMeso() * 40 / 100;
                            for (MaplePartyCharacter z : chr.getParty().getMembers()) {
                                MapleCharacter m = chr.getMap().getCharacterById(z.getId());
                                if ((m != null) && (m.getId() != chr.getId())) {
                                    toGive.add(m);
                                }
                            }
                            for (MapleCharacter m : toGive) {
                                m.gainMeso(splitMeso / toGive.size() + (m.getStat().hasPartyBonus ? (int) (mapitem.getMeso() / 20.0D) : 0), true);
                            }
                            chr.gainMeso(mapitem.getMeso() - splitMeso, true);
                        } else {
                            chr.gainMeso(mapitem.getMeso(), true);
                        }
                        removeItem_Pet(chr, mapitem, petz);
                    } else if ((MapleItemInformationProvider.getInstance().isPickupBlocked(mapitem.getItemId())) || (mapitem.getItemId() / 10000 == 291)) {
                        c.getSession().write(MaplePacketCreator.enableActions());
                    } else if (useItem(c, mapitem.getItemId())) {
                        removeItem_Pet(chr, mapitem, petz);
                    } else if (MapleInventoryManipulator.checkSpace(c, mapitem.getItemId(), mapitem.getItem().getQuantity(), mapitem.getItem().getOwner())) {
                        for (Iterator i$ = chr.getExcluded().iterator(); i$.hasNext();) {
                            int i = ((Integer) i$.next()).intValue();
                            if (mapitem.getItem().getItemId() == i) {
                                return;
                            }
                        }
                        if ((mapitem.getItem().getQuantity() >= 50) && (mapitem.getItemId() == 2340000)) {
                            c.setMonitored(true);
                        }
                        MapleInventoryManipulator.addFromDrop(c, mapitem.getItem(), true, mapitem.getDropper() instanceof MapleMonster);
                        removeItem_Pet(chr, mapitem, petz);
                    }
                }
            }
        } finally {
            lock.unlock();
        }
    }

    public static boolean useItem(MapleClient c, int id) {
        if (GameConstants.isUse(id)) {
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            MapleStatEffect eff = ii.getItemEffect(id);
            if (eff == null) {
                return false;
            }

            if (id / 10000 == 291) {
                boolean area = false;
                for (Rectangle rect : c.getPlayer().getMap().getAreas()) {
                    if (rect.contains(c.getPlayer().getTruePosition())) {
                        area = true;
                        break;
                    }
                }
                if ((!c.getPlayer().inPVP()) || ((c.getPlayer().getTeam() == id - 2910000) && (area))) {
                    return false;
                }
            }
            int consumeval = eff.getConsume();
            if (consumeval > 0) {
                consumeItem(c, eff);
                consumeItem(c, ii.getItemEffectEX(id));
                c.getSession().write(MaplePacketCreator.getShowItemGain(id, (short) 1));
                return true;
            }
        }
        return false;
    }

    public static void consumeItem(MapleClient c, MapleStatEffect eff) {
        if (eff == null) {
            return;
        }
        if (eff.getConsume() == 2) {
            if ((c.getPlayer().getParty() != null) && (c.getPlayer().isAlive())) {
                for (MaplePartyCharacter pc : c.getPlayer().getParty().getMembers()) {
                    MapleCharacter chr = c.getPlayer().getMap().getCharacterById(pc.getId());
                    if ((chr != null) && (chr.isAlive())) {
                        eff.applyTo(chr);
                    }
                }
            } else {
                eff.applyTo(c.getPlayer());
            }
        } else if (c.getPlayer().isAlive()) {
            eff.applyTo(c.getPlayer());
        }
    }

    public static void removeItem_Pet(MapleCharacter chr, MapleMapItem mapitem, int pet) {
        mapitem.setPickedUp(true);
        chr.getMap().broadcastMessage(MaplePacketCreator.物品消失在地图上(mapitem.getObjectId(), 5, chr.getId(), pet));
        chr.getMap().removeMapObject(mapitem);
        if (mapitem.isRandDrop()) {
            chr.getMap().spawnRandDrop();
        }
    }

    private static void removeItem(MapleCharacter chr, MapleMapItem mapitem, MapleMapObject ob) {
        mapitem.setPickedUp(true);
        chr.getMap().broadcastMessage(MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 2, chr.getId()), mapitem.getPosition());
        chr.getMap().removeMapObject(ob);
        if (mapitem.isRandDrop()) {
            chr.getMap().spawnRandDrop();
        }
    }

    public static void OwlMinerva(LittleEndianAccessor slea, MapleClient c) {
        byte slot = (byte) slea.readShort();
        int itemid = slea.readInt();
        Item toUse = c.getPlayer().getInventory(MapleInventoryType.USE).getItem((short) slot);
        if ((toUse != null) && (toUse.getQuantity() > 0) && (toUse.getItemId() == itemid) && (itemid == 2310000) && (!c.getPlayer().hasBlockedInventory())) {
            int itemSearch = slea.readInt();
            List hms = c.getChannelServer().searchMerchant(itemSearch);
            if (hms.size() > 0) {
                c.getSession().write(MaplePacketCreator.获取商店搜索器结果(itemSearch, hms));
                MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemid, 1, true, false);
            } else {
                c.getPlayer().dropMessage(1, "没有找到这个道具.");
            }
        }
        c.getSession().write(MaplePacketCreator.enableActions());
    }

    public static void Owl(LittleEndianAccessor slea, MapleClient c) {
        if ((c.getPlayer().getMapId() >= 910000000) && (c.getPlayer().getMapId() <= 910000022)) {
            c.getSession().write(MaplePacketCreator.获取商店搜索器());
        } else {
            c.getPlayer().dropMessage(5, "商店搜索器只能在自由市场使用.");
            c.getSession().write(MaplePacketCreator.enableActions());
        }
    }

    public static void OwlWarp(LittleEndianAccessor slea, MapleClient c) {
        c.getSession().write(MaplePacketCreator.enableActions());
        if ((c.getPlayer().getMapId() >= 910000000) && (c.getPlayer().getMapId() <= 910000022) && (!c.getPlayer().hasBlockedInventory())) {
            int id = slea.readInt();
            int type = slea.readByte();
            int map = slea.readInt();
            if ((map >= 910000001) && (map <= 910000022)) {
                MapleMap mapp = c.getChannelServer().getMapFactory().getMap(map);
                c.getPlayer().changeMap(mapp, mapp.getPortal(0));
                HiredMerchant merchant = null;
                switch (1) {
                    case 0:
                        List<MapleMapObject> objects = mapp.getAllHiredMerchantsThreadsafe();
                        objects = mapp.getAllHiredMerchantsThreadsafe();
                        for (MapleMapObject ob : objects) {
                            if ((ob instanceof IMaplePlayerShop)) {
                                IMaplePlayerShop ips = (IMaplePlayerShop) ob;
                                if ((ips instanceof HiredMerchant)) {
                                    HiredMerchant merch = (HiredMerchant) ips;
                                    if (merch.getOwnerId() == id) {
                                        merchant = merch;
                                        break;
                                    }
                                }
                            }
                        }
                        break;
                    case 1:
                        objects = mapp.getAllHiredMerchantsThreadsafe();
                        for (MapleMapObject ob : objects) {
                            if ((ob instanceof IMaplePlayerShop)) {
                                IMaplePlayerShop ips = (IMaplePlayerShop) ob;
                                if ((ips instanceof HiredMerchant)) {
                                    HiredMerchant merch = (HiredMerchant) ips;
                                    if (merch.getStoreId() == id) {
                                        merchant = merch;
                                        break;
                                    }
                                }
                            }
                        }
                        break;
                    default:
                        MapleMapObject ob = mapp.getMapObject(id, MapleMapObjectType.HIRED_MERCHANT);
                        if ((ob instanceof IMaplePlayerShop)) {
                            IMaplePlayerShop ips = (IMaplePlayerShop) ob;
                            if ((ips instanceof HiredMerchant)) {
                                merchant = (HiredMerchant) ips;
                            }
                        }
                        break;
                }
                if (merchant != null) {
                    if (merchant.isOwner(c.getPlayer())) {
                        merchant.setOpen(false);
                        merchant.removeAllVisitors(18, 1);
                        c.getPlayer().setPlayerShop(merchant);
                        c.getSession().write(PlayerShopPacket.getHiredMerch(c.getPlayer(), merchant, false));
                    } else if ((!merchant.isOpen()) || (!merchant.isAvailable())) {
                        c.getPlayer().dropMessage(1, "商店主人正在整理商店物品\r\n请稍后再度光临！");
                    } else if (merchant.getFreeSlot() == -1) {
                        c.getPlayer().dropMessage(1, "店铺已达到最大人数\r\n请稍后再度光临！");
                    } else if (merchant.isInBlackList(c.getPlayer().getName())) {
                        c.getPlayer().dropMessage(1, "你被禁止进入该店铺.");
                    } else {
                        c.getPlayer().setPlayerShop(merchant);
                        merchant.addVisitor(c.getPlayer());
                        c.getSession().write(PlayerShopPacket.getHiredMerch(c.getPlayer(), merchant, false));
                    }
                } else {
                    c.getPlayer().dropMessage(1, "商店主人正在整理商店物品\r\n请稍后再度光临！");
                }
            }
        }
    }

    public static void PamSong(LittleEndianAccessor slea, MapleClient c) {
        Item pam = c.getPlayer().getInventory(MapleInventoryType.CASH).findById(5640000);
        if ((slea.readByte() > 0) && (c.getPlayer().getScrolledPosition() != 0) && (pam != null) && (pam.getQuantity() > 0)) {
            MapleInventoryType inv = c.getPlayer().getScrolledPosition() < 0 ? MapleInventoryType.EQUIPPED : MapleInventoryType.EQUIP;
            Item item = c.getPlayer().getInventory(inv).getItem(c.getPlayer().getScrolledPosition());
            c.getPlayer().setScrolledPosition((short) 0);
            if (item != null) {
                Equip eq = (Equip) item;
                eq.setUpgradeSlots((byte) (eq.getUpgradeSlots() + 1));
                c.getPlayer().forceReAddItem_Flag(eq, inv);
                MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.CASH, pam.getPosition(), (short) 1, true, false);
                c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.pamsSongEffect(c.getPlayer().getId()));
            }
        } else {
            c.getPlayer().setScrolledPosition((short) 0);
        }
    }

    public static void TeleRock(LittleEndianAccessor slea, MapleClient c) {
        byte slot = (byte) slea.readShort();
        int itemId = slea.readInt();
        Item toUse = c.getPlayer().getInventory(MapleInventoryType.USE).getItem((short) slot);
        if ((toUse == null) || (toUse.getQuantity() < 1) || (toUse.getItemId() != itemId) || (itemId / 10000 != 232) || (c.getPlayer().hasBlockedInventory())) {
            c.getSession().write(MaplePacketCreator.enableActions());
            return;
        }
        boolean used = UseTeleRock(slea, c, itemId);
        if (used) {
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (short) slot, (short) 1, false);
        }
        c.getSession().write(MaplePacketCreator.enableActions());
    }

    public static boolean UseTeleRock(LittleEndianAccessor slea, MapleClient c, int itemId) {
        boolean used = false;
        if (slea.readByte() == 0) {
            MapleMap target = c.getChannelServer().getMapFactory().getMap(slea.readInt());
            if (((itemId == 5041000) && (c.getPlayer().isRockMap(target.getId()))) || ((itemId != 5041000) && (c.getPlayer().isRegRockMap(target.getId()))) || (((itemId == 5040004) || (itemId == 5041001)) && ((c.getPlayer().isHyperRockMap(target.getId())) || (GameConstants.isHyperTeleMap(target.getId()))) && (!FieldLimitType.VipRock.check(c.getPlayer().getMap().getFieldLimit())) && (!FieldLimitType.VipRock.check(target.getFieldLimit())) && (!c.getPlayer().isInBlockedMap()))) {
                c.getPlayer().changeMap(target, target.getPortal(0));
                used = true;
            }
        } else {
            MapleCharacter victim = c.getChannelServer().getPlayerStorage().getCharacterByName(slea.readMapleAsciiString());
            if ((victim != null) && (!victim.isIntern()) && (c.getPlayer().getEventInstance() == null) && (victim.getEventInstance() == null)) {
                if ((!FieldLimitType.VipRock.check(c.getPlayer().getMap().getFieldLimit())) && (!FieldLimitType.VipRock.check(c.getChannelServer().getMapFactory().getMap(victim.getMapId()).getFieldLimit())) && (!victim.isInBlockedMap()) && (!c.getPlayer().isInBlockedMap()) && ((itemId == 5041000) || (itemId == 5040004) || (itemId == 5041001) || (victim.getMapId() / 100000000 == c.getPlayer().getMapId() / 100000000))) {
                    c.getPlayer().changeMap(victim.getMap(), victim.getMap().findClosestPortal(victim.getTruePosition()));
                    used = true;
                }
            } else {
                c.getPlayer().dropMessage(1, "在此频道未找到该玩家.");
            }
        }

        return used;
    }

    public static void UseNebulite(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        chr.updateTick(slea.readInt());
        chr.setScrolledPosition((short) 0);
        Item nebulite = chr.getInventory(MapleInventoryType.SETUP).getItem((short) (byte) slea.readShort());
        int nebuliteId = slea.readInt();
        Item toMount = chr.getInventory(MapleInventoryType.EQUIP).getItem((short) (byte) slea.readShort());
        if ((nebulite == null) || (nebuliteId != nebulite.getItemId()) || (toMount == null) || (chr.hasBlockedInventory())) {
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return;
        }
        Equip eqq = (Equip) toMount;
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        boolean success = false;
        if (eqq.getSocket1() == 0) {
            StructItemOption pot = ii.getSocketInfo(nebuliteId);
            if ((pot != null) && (GameConstants.optionTypeFits(pot.optionType, eqq.getItemId()))) {
                eqq.setSocket1(pot.opID);
            }

            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.SETUP, nebulite.getPosition(), (short) 1, false);
            chr.forceReAddItem(toMount, MapleInventoryType.EQUIP);
            success = true;
        }
        chr.getMap().broadcastMessage(MaplePacketCreator.显示星岩效果(c.getPlayer().getId(), success));
        c.getSession().write(MaplePacketCreator.enableActions());
    }

    public static void UseAlienSocket(LittleEndianAccessor slea, MapleClient c) {
        c.getPlayer().updateTick(slea.readInt());
        c.getPlayer().setScrolledPosition((short) 0);
        Item alienSocket = c.getPlayer().getInventory(MapleInventoryType.USE).getItem((short) (byte) slea.readShort());
        int alienSocketId = slea.readInt();
        Item toMount = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((short) (byte) slea.readShort());
        if ((alienSocket == null) || (alienSocketId != alienSocket.getItemId()) || (toMount == null) || (c.getPlayer().hasBlockedInventory())) {
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return;
        }

        Equip eqq = (Equip) toMount;
        if (eqq.getSocketState() != 0) {
            c.getPlayer().dropMessage(1, "This item already has a socket.");
        } else {
            eqq.setSocket1(0);
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, alienSocket.getPosition(), (short) 1, false);
            c.getPlayer().forceReAddItem(toMount, MapleInventoryType.EQUIP);
        }
        c.getSession().write(MTSCSPacket.useAlienSocket(true));
    }

    public static void UseNebuliteFusion(LittleEndianAccessor slea, MapleClient c) {
        c.getPlayer().updateTick(slea.readInt());
        c.getPlayer().setScrolledPosition((short) 0);
        int nebuliteId1 = slea.readInt();
        Item nebulite1 = c.getPlayer().getInventory(MapleInventoryType.SETUP).getItem((short) (byte) slea.readShort());
        int nebuliteId2 = slea.readInt();
        Item nebulite2 = c.getPlayer().getInventory(MapleInventoryType.SETUP).getItem((short) (byte) slea.readShort());
        int mesos = slea.readInt();
        int premiumQuantity = slea.readInt();
        if ((nebulite1 == null) || (nebulite2 == null) || (nebuliteId1 != nebulite1.getItemId()) || (nebuliteId2 != nebulite2.getItemId()) || ((mesos == 0) && (premiumQuantity == 0)) || ((mesos != 0) && (premiumQuantity != 0)) || (mesos < 0) || (premiumQuantity < 0) || (c.getPlayer().hasBlockedInventory())) {
            c.getPlayer().dropMessage(1, "Failed to fuse Nebulite.");
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return;
        }
        int grade1 = GameConstants.getNebuliteGrade(nebuliteId1);
        int grade2 = GameConstants.getNebuliteGrade(nebuliteId2);
        int highestRank = grade1 > grade2 ? grade1 : grade2;
        if ((grade1 == -1) || (grade2 == -1) || ((highestRank == 3) && (premiumQuantity != 2)) || ((highestRank == 2) && (premiumQuantity != 1)) || ((highestRank == 1) && (mesos != 5000)) || ((highestRank == 0) && (mesos != 3000)) || ((mesos > 0) && (c.getPlayer().getMeso() < mesos)) || ((premiumQuantity > 0) && (c.getPlayer().getItemQuantity(4420000, false) < premiumQuantity)) || (grade1 >= 4) || (grade2 >= 4) || (c.getPlayer().getInventory(MapleInventoryType.SETUP).getNumFreeSlot() < 1)) {
            c.getSession().write(MaplePacketCreator.useNebuliteFusion(c.getPlayer().getId(), 0, false));
            return;
        }
        int avg = (grade1 + grade2) / 2;
        int rank = avg != 3 ? avg + 1 : Randomizer.nextInt(100) < 70 ? avg : avg != 0 ? avg - 1 : Randomizer.nextInt(100) < 4 ? 0 : avg;

        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        List pots = new LinkedList(ii.getAllSocketInfo(rank).values());
        int newId = 0;
        while (newId == 0) {
            StructItemOption pot = (StructItemOption) pots.get(Randomizer.nextInt(pots.size()));
            if (pot != null) {
                newId = pot.opID;
            }
        }
        if (mesos > 0) {
            c.getPlayer().gainMeso(-mesos, true);
        } else if (premiumQuantity > 0) {
            MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, 4420000, premiumQuantity, false, false);
        }
        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.SETUP, nebulite1.getPosition(), (short) 1, false);
        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.SETUP, nebulite2.getPosition(), (short) 1, false);
        MapleInventoryManipulator.addById(c, newId, (short) 1, new StringBuilder().append("Fused from ").append(nebuliteId1).append(" and ").append(nebuliteId2).append(" on ").append(FileoutputUtil.CurrentReadable_Date()).toString());
        c.getSession().write(MaplePacketCreator.useNebuliteFusion(c.getPlayer().getId(), newId, true));
    }

    public static void 使用灵魂卷轴(short 使用卷轴所在位置, short 附加装备所在位置, MapleClient c, MapleCharacter chr) {
        boolean 新砸卷对话框 = false;
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        chr.setScrolledPosition((short) 0);

        if (附加装备所在位置 < 0) {
            chr.dropMessage(1, "该物品不支持这样使用，请使用快捷砸卷进行！");
            chr.getClient().getSession().write(MaplePacketCreator.enableActions());
            return;
        }

        新砸卷对话框 = true;
        Equip 装备 = (Equip) chr.getInventory(MapleInventoryType.EQUIP).getItem(附加装备所在位置);

        if (chr.isAdmin()) {
            chr.dropMessage(-9, new StringBuilder().append("开始为装备附加灵魂卷轴  附加装备所在位置 = ").append(附加装备所在位置).toString());
        }
        Item scroll = chr.getInventory(MapleInventoryType.USE).getItem(使用卷轴所在位置);
        if (scroll == null) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, "砸卷错误: scroll == null");
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return;
        }
        if (chr.isAdmin()) {
            chr.dropMessage(-9, new StringBuilder().append("2砸卷信息: 卷轴ID ").append(scroll.getItemId()).append(" 卷轴名字 ").append(ii.getName(scroll.getItemId())).toString());
        }
        if (GameConstants.is灵魂卷轴(scroll.getItemId())) {
            if (装备.getIsHunWuQi() != 0) {
                chr.dropMessage(1, new StringBuilder().append("当前装备已经附加灵魂卷轴！").toString());
                c.getSession().write(MaplePacketCreator.getInventoryFull());
                return;
            }
            boolean 是否成功 = true;
            int 成功率 = 10;
            if (chr.isLvkejian()) {
                成功率 += 60;
            }
            if (Randomizer.nextInt(100) <= 成功率) {
                装备.setIsHunWuQi(1);
                c.getSession().write(MaplePacketCreator.scrolledItem(scroll, 装备, false, 附加装备所在位置 < 0));
                chr.getMap().broadcastMessage(chr, MaplePacketCreator.getScrollEffect(chr.getId(), Equip.ScrollResult.成功, false, false, scroll.getItemId(), 装备.getItemId()), true);
            } else {
                是否成功 = false;
                c.getPlayer().dropMessage(-11, "使用灵魂卷轴失败！");
                c.getPlayer().dropMessage(-1, "使用灵魂卷轴失败！");

                c.getSession().write(MaplePacketCreator.getInventoryFull());
                c.getSession().write(MaplePacketCreator.scrolledItem(scroll, 装备, false, 附加装备所在位置 < 0));
                chr.getMap().broadcastMessage(chr, MaplePacketCreator.getScrollEffect(chr.getId(), Equip.ScrollResult.失败, false, false, scroll.getItemId(), 装备.getItemId()), true);
                chr.setScrolledPosition(装备.getPosition());
                c.getSession().write(MaplePacketCreator.pamSongUI());
            }

            if (新砸卷对话框 == true);
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, scroll.getPosition(), (short) 1, false);
        }

        if (附加装备所在位置 < 0) {
            chr.equipChanged();
        }
        chr.getClient().getSession().write(MaplePacketCreator.enableActions());
    }

    public static void 使用灵魂宝珠(short 使用卷轴所在位置, short 附加装备所在位置, MapleClient c, MapleCharacter chr) {
        boolean 新砸卷对话框 = false;
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        chr.setScrolledPosition((short) 0);

        if (附加装备所在位置 < 0) {
            chr.dropMessage(1, "该物品不支持这样使用，请使用快捷砸卷进行！");
            chr.getClient().getSession().write(MaplePacketCreator.enableActions());
            return;
        }

        新砸卷对话框 = true;
        Equip 装备 = (Equip) chr.getInventory(MapleInventoryType.EQUIP).getItem(附加装备所在位置);

        if (chr.isAdmin()) {
            chr.dropMessage(-9, new StringBuilder().append("开始为装备附加灵魂卷轴  附加装备所在位置 = ").append(附加装备所在位置).toString());
        }
        Item scroll = chr.getInventory(MapleInventoryType.USE).getItem(使用卷轴所在位置);
        if (scroll == null) {
            if (chr.isAdmin()) {
                chr.dropMessage(-9, "砸卷错误: scroll == null");
            }
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            return;
        }
        if (chr.isAdmin()) {
            chr.dropMessage(-9, new StringBuilder().append("3砸卷信息: 卷轴ID ").append(scroll.getItemId()).append(" 卷轴名字 ").append(ii.getName(scroll.getItemId())).toString());
        }
        if (GameConstants.is灵魂宝珠(scroll.getItemId())) {
            boolean 是否成功 = true;
            int 成功率 = 25;
            if (chr.isLvkejian()) {
                成功率 += 60;
            }
            if (Randomizer.nextInt(100) <= 成功率) {
                装备.setHunWuQiType(scroll.getItemId() - 2591000 + 1);
                if (装备.getPotential7() != 0) {
                    装备.setPotential7(0);
                }
                int 附加潜能7等级 = 20;
                if (Randomizer.nextInt(200) <= 1) {
                    附加潜能7等级 = 21;
                } else if (Randomizer.nextInt(200) <= 3) {
                    附加潜能7等级 = 22;
                } else if (Randomizer.nextInt(200) <= 55) {
                    附加潜能7等级 = 23;
                }
                String 消息 = "附加灵魂宝珠潜能: ";
                boolean 鉴定潜能7成功 = false;
                List pots = new LinkedList(ii.getAllPotentialInfo().values());
                int reqLevel = ii.getReqLevel(装备.getItemId()) / 10;
                while ((装备.取得潜能等级(7) != 附加潜能7等级) && (!鉴定潜能7成功)) {
                    int 执行次数7 = 0;
                    while (!鉴定潜能7成功) {
                        执行次数7++;
                        StructItemOption pot = (StructItemOption) ((List) pots.get(Randomizer.nextInt(pots.size()))).get(reqLevel);
                        if ((pot != null) && (pot.reqLevel / 10 <= reqLevel) && (GameConstants.optionTypeFits(pot.optionType, 装备.getItemId())) && (GameConstants.optionTypeFitsX(pot.opID, 装备.getItemId())) && (GameConstants.加载潜能是否符合潜能等级(pot.opID, 附加潜能7等级))) {
                            装备.setPotential7(pot.opID);
                            鉴定潜能7成功 = true;
                        }

                        if (执行次数7 > 60010) {
                            装备.setPotential7(pot.opID);
                            鉴定潜能7成功 = true;
                        }
                    }
                    if ((装备.取得潜能等级(7) == 附加潜能7等级) && (鉴定潜能7成功 == true)) {
                        消息 = new StringBuilder().append(消息).append(" 潜能7ID:").append(装备.getPotential7()).append(" 执行次数7: ").append(执行次数7).toString();
                    }
                }
                if (chr.isLvkejian()) {
                    chr.dropMessage(-11, 消息);
                }
                c.getSession().write(MaplePacketCreator.scrolledItem(scroll, 装备, false, 附加装备所在位置 < 0));
                chr.getMap().broadcastMessage(chr, MaplePacketCreator.getScrollEffect(chr.getId(), Equip.ScrollResult.成功, false, false, scroll.getItemId(), 装备.getItemId()), true);
            } else {
                是否成功 = false;
                c.getPlayer().dropMessage(-11, "使用灵魂宝珠失败！");
                c.getPlayer().dropMessage(-1, "使用灵魂宝珠失败！");

                c.getSession().write(MaplePacketCreator.getInventoryFull());
                c.getSession().write(MaplePacketCreator.scrolledItem(scroll, 装备, false, 附加装备所在位置 < 0));
                chr.getMap().broadcastMessage(chr, MaplePacketCreator.getScrollEffect(chr.getId(), Equip.ScrollResult.失败, false, false, scroll.getItemId(), 装备.getItemId()), true);
                chr.setScrolledPosition(装备.getPosition());
                c.getSession().write(MaplePacketCreator.pamSongUI());
            }

            if (新砸卷对话框 == true);
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, scroll.getPosition(), (short) 1, false);
        }

        if (附加装备所在位置 < 0) {
            chr.equipChanged();
        }
        chr.getClient().getSession().write(MaplePacketCreator.enableActions());
    }

    public static void 组合卷轴(int 第一张, int 第二张, int 第三张, int 第四张, int 第五张, MapleClient c, MapleCharacter chr) {
        int itemid = 2028158;
        if (Randomizer.nextInt(100) <= 30) {
            itemid = 2028159;
        } else if (Randomizer.nextInt(100) > 60);
        MapleInventoryManipulator.addById(c, itemid, (short) 1, new StringBuilder().append("组合卷轴 ").append(FileoutputUtil.CurrentReadable_Date()).toString());
        MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, 第一张, 1, true, true);
        MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, 第二张, 1, true, true);
        MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, 第三张, 1, true, true);
        MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, 第四张, 1, true, true);
        MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, 第五张, 1, true, true);

        chr.getClient().getSession().write(MaplePacketCreator.enableActions());
    }

    public static void 更新_神之子_武器(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        int itemid = slea.readInt();
        int nextItemid = itemid + 1;
        short dst = -11;
        boolean is神之子_贝塔_武器 = false;

        int 类型 = 1;
        if ((chr.hasEquipped(1572001)) && (chr.hasEquipped(1572001))) {
            类型 = 2;
        } else if ((chr.hasEquipped(1572002)) && (chr.hasEquipped(1572002))) {
            类型 = 3;
        } else if ((chr.hasEquipped(1572003)) && (chr.hasEquipped(1572003))) {
            类型 = 4;
        } else if ((chr.hasEquipped(1572004)) && (chr.hasEquipped(1572004))) {
            类型 = 5;
        } else if ((chr.hasEquipped(1572005)) && (chr.hasEquipped(1572005))) {
            类型 = 6;
        } else if ((chr.hasEquipped(1572006)) && (chr.hasEquipped(1572006))) {
            类型 = 7;
        }
        int 升级需要的WP点 = GameConstants.is神之子_武器_需要WP(类型);
        int haveWP = chr.get神之子_武器点数();
        if ((!GameConstants.is神之子_贝塔_武器(nextItemid)) && (!GameConstants.is神之子_阿尔法_武器(nextItemid))) {
            chr.dropMessage(1, new StringBuilder().append(" nextItemid = ").append(nextItemid).append(" 不是神之子武器装备！").toString());
            return;
        }
        if (chr.isAdmin()) {
            chr.dropMessage(-9, new StringBuilder().append("开始更新神之子装备 --- ItemId = ").append(itemid).append(" dst = ").append(dst).append(" nextItemid = ").append(nextItemid).toString());
        }
        if (haveWP < 升级需要的WP点) {
            chr.dropMessage(1, new StringBuilder().append(" 升级需要的 WP点 不足！\r\n本次升级需要 WP点 ").append(升级需要的WP点).append("\r\n当前您的 WP点 为 ").append(haveWP).append("\r\n下一阶段武器的攻击力为 ").append(类型 * (10 + 类型 * 10) + 100).append("\r\n打怪获得WP  5000 WP 哦！\r\n需要赶快联系六月吧！").toString());
            return;
        }
        if ((类型 == 6) || (类型 == 7)) {
            if (chr.getItemQuantity(4033999) >= 1) {
                MapleInventoryManipulator.removeById(c, GameConstants.getInventoryType(4033999), 4033999, 1, true, false);
            } else {
                chr.dropMessage(1, " 对不起，你没有一个封印的时间之石，无法升级武器！");
                return;
            }
        }
        chr.add神之子_武器点数(-升级需要的WP点);
        if (!is神之子_贝塔_武器) {
            更新_神之子_武器_属性(nextItemid, dst, 类型, is神之子_贝塔_武器, c, chr);
            is神之子_贝塔_武器 = true;
            nextItemid -= 10000;
            dst = -10;
        }
        if (is神之子_贝塔_武器 == true) {
            更新_神之子_武器_属性(nextItemid, dst, 类型, is神之子_贝塔_武器, c, chr);
        }
        chr.dropMessage(1, new StringBuilder().append("消耗 WP点 ").append(升级需要的WP点).append(" 升级武器成功！\r\n每次升级的属性都会翻倍提高的哦！\r\n最后一级将会成为 355 攻击的魂武器哦！").toString());
    }

    public static void 更新_神之子_武器_属性(int nextItemid, short dst, int 类型, boolean is神之子_贝塔_武器, MapleClient c, MapleCharacter chr) {

        int 潜能1 = GameConstants.is神之子_武器_潜能1(类型);
        int 潜能2 = GameConstants.is神之子_武器_潜能2(类型);
        int 潜能3 = GameConstants.is神之子_武器_潜能3(类型);
        Equip toScroll = (Equip) chr.getInventory(MapleInventoryType.EQUIPPED).getItem(dst);
        toScroll.setItemId(nextItemid);
        toScroll.setStr((short) (类型 * (50 + 类型 * 10)));
        toScroll.setDex((short) (类型 * (30 + 类型 * 10)));
        toScroll.setHp((short) (类型 * 1000));
        toScroll.setMp((short) (类型 * 1000));
        toScroll.setAcc((short) (类型 * 100 + 200));
        toScroll.setWatk((short) (类型 * (10 + 类型 * 10) + 100));
        toScroll.setWdef((short) (类型 * 300 + 200));
        toScroll.setMdef((short) (类型 * 300 + 200));
        toScroll.setSpeed((short) (类型 * 5 + 25));
        toScroll.setJump((short) (类型 * 2 + 9));
        toScroll.setAvoid((short) (类型 * 100 + 200));
        toScroll.setPotential1(潜能1);
        toScroll.setPotential2(潜能2);
        toScroll.setPotential3(潜能3);
        toScroll.setPotential4((类型 == 6) || (类型 == 7) ? 潜能1 : 0);
        toScroll.setPotential5((类型 == 6) || (类型 == 7) ? 潜能2 : 0);
        toScroll.setPotential6((类型 == 6) || (类型 == 7) ? 潜能1 : 0);
        toScroll.setPotential7(类型 == 7 ? 潜能3 : 0);
        toScroll.setState(toScroll.getState());
        toScroll.setIsHunWuQi(类型 == 7 ? 1 : 0);
        toScroll.setHunWuQiType(类型 == 7 ? 4 : 0);
        toScroll.setMaxDamage(类型 == 2 ? 9999999 : 类型 == 3 ? 1999999 : 类型 == 4 ? 2999999 : 类型 == 5 ? 3999999 : 类型 == 6 ? 4999999 : 类型 == 7 ? 9999999 : 999999);
        toScroll.setBOSSDamage((类型 == 7 ? 10 : 类型) * 10);
        toScroll.setWSMD((类型 == 7 ? 10 : 类型) * 10);
        toScroll.setUpgradeSlots((byte) (7 + 类型 * 2));
        c.getPlayer().forceReAddItem(toScroll, MapleInventoryType.EQUIP);
        c.getSession().write(MaplePacketCreator.enableActions());
        c.getSession().write(MaplePacketCreator.更新_神之子_武器(toScroll, !is神之子_贝塔_武器));
        chr.equipChanged();
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        String medal = "<神之子>";
        Item medalItem = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short) -26);
        if (medalItem != null) {
            medal = new StringBuilder().append("<").append(ii.getName(medalItem.getItemId())).append("> ").toString();
        }
        chr.Maplem(new StringBuilder().append("<神之子> 恭喜  ").append(chr.getName()).append("  成功升级武器到 ").append(类型).append(" 段！ <神之子>").toString(), 5121009);
        String msg = new StringBuilder().append(medal).append(c.getPlayer().getName()).append(" : 成功升级武器！").toString();
        Broadcast.broadcastSmega(MaplePacketCreator.喇叭_道具(msg, true, c.getChannel(), toScroll));
    }

    public static void 品克缤_敲敲窗口(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        int 使用类型 = slea.readInt();
        int 物品id = slea.readInt();
        boolean 是否进入下一阶段 = (物品id - 5224000) % 2 == 0;
        if (物品id == 5224000) {
            是否进入下一阶段 = false;
        }
        c.getSession().write(MaplePacketCreator.品克缤敲敲_窗口(物品id, 是否进入下一阶段));
    }

    public static void 品克缤_敲敲确认(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
        slea.skip(4);
        int 使用类型 = slea.readInt();
        int 物品id = slea.readInt();
        int nxitem = 物品id + 1;
        if (nxitem > 5224008) {
            nxitem = 5224000;
        }
        MapleItemInformationProvider iis = MapleItemInformationProvider.getInstance();
        if ((chr.getSpace(1) >= 1) && (chr.getSpace(2) >= 1) && (chr.getSpace(3) >= 1) && (chr.getSpace(4) >= 1) && (chr.getSpace(5) >= 1)) {
            if (chr.getItemQuantity(物品id) >= 1) {
                int reward = GameConstants.取得抽奖物品(200);
                Item items = MapleInventoryManipulator.addbyId_Gachapon(c, reward, (short) 1);
                if (items == null) {
                    c.getPlayer().dropMessage(1, "获取 品克缤敲敲 里的物品失败(所抽取的数据不存在)，请重试一次。");
                    c.getSession().write(MaplePacketCreator.enableActions());
                } else {
                    MapleInventoryManipulator.removeById(c, GameConstants.getInventoryType(物品id), 物品id, 1, true, false);
                    MapleInventoryManipulator.removeById(c, GameConstants.getInventoryType(nxitem), nxitem, -1, true, false);
                    c.getSession().write(MaplePacketCreator.品克缤_敲敲_完成(true, 物品id));
                    c.getSession().write(MaplePacketCreator.品克缤_敲敲_获得物品(物品id));
                    c.getSession().write(MaplePacketCreator.品克缤_敲敲_显示获得物品_1("Effect/BasicEff/Event1/Best", 物品id));
                    c.getSession().write(MaplePacketCreator.品克缤_敲敲_显示获得物品_2(物品id));
                    c.getSession().write(MaplePacketCreator.getShowItemGain(reward, (short) 1, true));

                    World.Broadcast.broadcastMessage(MaplePacketCreator.转蛋机喇叭(c.getPlayer().getName(), new StringBuilder().append(" : 从 品克缤敲敲乐 中获得{").append(iis.getName(items.getItemId())).append("}！大家一起恭喜他（她）吧！！！！").toString(), items, (byte) 2, c.getChannel()));
                }
            } else {
                chr.dropMessage(1, " 对不起，你没有一个品克缤敲敲乐！");
                c.getSession().write(MaplePacketCreator.品克缤_敲敲_完成(false, 物品id));
            }
        } else {
            c.getSession().write(MaplePacketCreator.品克缤_敲敲_完成(false, 物品id));
        }
    }
}